{-# LANGUAGE TupleSections #-}
import Data.List
main = do
  n <- readLn
  let edges = g $ f n
  print $ length edges
  mapM_ printT edges

f :: Int -> [[Int]]
f x
  | odd x     = [x] : f (x-1)
  | otherwise = zipWith (\a b -> [a,b]) [1..x `div` 2] [x,x-1..]

g :: [[Int]] -> [(Int, Int)]
g [] = []
g (x:xs) = ((,) <$> x <*> concat xs) ++ g xs

printT (a,b) = putStrLn $ show a ++ " " ++ show b