import qualified Data.ByteString.Char8 as BS
import Data.Maybe

permu3 :: Int -> Int -> Int -> Int
permu3 a b c
    | a==b && b==c         = 1
    | a==b || b==c || c==a = 3
    | otherwise            = 6

main :: IO ()
main = do 
    n <- fst . fromJust <$> ( BS.readInt <$> BS.getLine ) :: IO Int
    let t1 = 
            [ permu3 a b c * foldl1 gcd [a,b,c]
            | a <- [1..n], b <- [a..n], c <- [b..n]
            ]
    print $ sum t1
