import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class nB {

	Scanner in;
	PrintWriter out;

	void solve() {
		int n = in.nextInt();
		out.println(n - 2);
		for (int i = 0; i < n - 1; i++) {
			out.print(1 + " ");
		}
		out.println();
		ArrayList<Integer> list = new ArrayList<Integer>();
		for (int i = 2; i < n - 1; i++) {
			list.add(i);
		}
		list.add(n - 2);
		for (int i = 1; i < n - 1; i++) {
			for (int x : list) {
				out.print(x + " ");
			}
			out.println();
			if (i != n - 2) {
				list.remove(1);
			}
		}
	}

	void run() {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
		try {
			solve();
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) {
		new nB().run();
	}

}
