N = int(input()) D = [0]*(N+1) E = [(1,2)] D[1] += 1 D[2] += 1 x = 1 for n in range(3,N+1): flag = 0 for i in range(1,n): if D[i]>x: D[i] += 1 D[n] += 1 E.append((n,i)) elif D[i]==x and flag==0: D[i] += 1 D[n] += 1 E.append((n,i)) flag = 1 x = D[n] print(len(E)) for u,v in E: print(u,v)