#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10000;
const int INF = 0x7FFFFFFF;
const double eps = 1e-10;
const double pi = acos(-1.0);
int n, ret, now;
int t[MAXN / 8];
short a[MAXN / 8][MAXN / 8];
int main() {
  cin >> n;
  t[1] = 1;
  t[2] = 1;
  ret = 2;
  now = 2;
  a[1][1] = 1;
  a[2][1] = 1;
  while (now <= n) {
    if (now + ret - 1 > n) break;
    ++ret;
    a[ret][1] = now;
    t[ret] = 1;
    for (int i = 1; i < ret; i++) {
      a[i][++t[i]] = now++;
      if (i != 1) a[ret][++t[ret]] = a[i][t[i]];
    }
  }
  for (int i = 1; i <= ret; i++)
    if (a[i][t[i]] > n) {
      ret = i - 1;
      break;
    }
  cout << ret << endl;
  for (int i = 1; i <= ret; i++) {
    for (int j = 1; j <= t[i]; j++) {
      if (j > 1) cout << ' ';
      cout << a[i][j];
    }
    cout << endl;
  }
}
