n = gets.to_i
m = n*(n+1)/2
for i in 2..n
    next if m%i != 0
    a = Array.new(i).map{[]}
    s = m/i
    used = Array.new(n,false)
    for j in 0..i-1
        t = 0
        n.downto(1) do |k|
            if t+k <= s && used[k-1] == false
                used[k-1] = true
                t += k
                a[j] << k
            end
        end
    end
    ls = Array.new(n).map{Array.new(n,true)}
    for j in 0..i-1
        a[j].each do |x|
            a[j].each do |y|
                ls[x-1][y-1] = false
            end
        end
    end
    cnt = 0
    for j in 0..n-1
        for k in j..n-1
            cnt += 1 if ls[j][k]
        end
    end
    puts cnt
    for j in 0..n-1
        for k in j..n-1
            puts "#{j+1} #{k+1}" if ls[j][k]
        end
    end
    break
end