#include <iostream>
#include <cstdio>

using namespace std;

int f(int x, int y) {
	for (int k = 0; ; ++k)
		if ( (x&(1<<k))^(y&(1<<k)))
			return k + 1;
}

void solve() {
	int N;
	cin >> N;
	int k = 1;
	while ((1<<k) < N) ++k;
	cout << k << endl;
	for (int i = 0; i < N - 1; ++i) {
		for (int j = i + 1; j < N; ++j) {
			if (j != i + 1)
				cout << ' ';
			cout << f(i, j);
		}
		cout << endl;
	}
}

int main() {
	solve();
	
	return 0;
}
