

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int max = sc.nextInt();
		
		long result = 0;
		
		long kouyaku = 1;
		
		for(int a = 1; a <= max; a++) {
		
			for(int b = 1; b <= max; b++) {
			
				for(int c= 1; c <= max; c++) {
				
					int ap = a;
					
					int bp = b;
					
					int cp = c;
					
					for(int j= 1; j <= ap && j <= bp && j <= cp; j++) {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					}
						
						result += kouyaku;
						
						kouyaku = 1;
						
					}
					
				}
			}
		
						
		
		sc.close();
		
		System.out.println(result);
		
	}
	
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int max = sc.nextInt();
		
		long result = 0;
		
		long kouyaku = 1;
		
		for(int a = 1; a <= max; a++) {
		
			for(int b = 1; b <= max; b++) {
			
				for(int c= 1; c <= max; c++) {
				
					int ap = a;
					
					int bp = b;
					
					int cp = c;
					
					for(int j= 1; j <= ap && j <= bp && j <= cp; j++) {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					}
						
						result += kouyaku;
						
						kouyaku = 1;
						
					}
					
				}
			}
		
						
		
		sc.close();
		
		System.out.println(result);
		
	}
	
} Main public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int max = sc.nextInt();
		
		long result = 0;
		
		long kouyaku = 1;
		
		for(int a = 1; a <= max; a++) {
		
			for(int b = 1; b <= max; b++) {
			
				for(int c= 1; c <= max; c++) {
				
					int ap = a;
					
					int bp = b;
					
					int cp = c;
					
					for(int j= 1; j <= ap && j <= bp && j <= cp; j++) {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					}
						
						result += kouyaku;
						
						kouyaku = 1;
						
					}
					
				}
			}
		
						
		
		sc.close();
		
		System.out.println(result);
		
	} main {
		
		Scanner sc = new Scanner(System.in);
		
		int max = sc.nextInt();
		
		long result = 0;
		
		long kouyaku = 1;
		
		for(int a = 1; a <= max; a++) {
		
			for(int b = 1; b <= max; b++) {
			
				for(int c= 1; c <= max; c++) {
				
					int ap = a;
					
					int bp = b;
					
					int cp = c;
					
					for(int j= 1; j <= ap && j <= bp && j <= cp; j++) {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					}
						
						result += kouyaku;
						
						kouyaku = 1;
						
					}
					
				}
			}
		
						
		
		sc.close();
		
		System.out.println(result);
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int max = sc.nextInt(); max sc.nextInt() sc.nextInt sc long result = 0; result 0 long kouyaku = 1; kouyaku 1 for(int a = 1; a <= max; a++) {
		
			for(int b = 1; b <= max; b++) {
			
				for(int c= 1; c <= max; c++) {
				
					int ap = a;
					
					int bp = b;
					
					int cp = c;
					
					for(int j= 1; j <= ap && j <= bp && j <= cp; j++) {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					}
						
						result += kouyaku;
						
						kouyaku = 1;
						
					}
					
				}
			} int a = 1; int a = 1; a 1 a <= max a max a++ a++ a {
		
			for(int b = 1; b <= max; b++) {
			
				for(int c= 1; c <= max; c++) {
				
					int ap = a;
					
					int bp = b;
					
					int cp = c;
					
					for(int j= 1; j <= ap && j <= bp && j <= cp; j++) {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					}
						
						result += kouyaku;
						
						kouyaku = 1;
						
					}
					
				}
			} {
		
			for(int b = 1; b <= max; b++) {
			
				for(int c= 1; c <= max; c++) {
				
					int ap = a;
					
					int bp = b;
					
					int cp = c;
					
					for(int j= 1; j <= ap && j <= bp && j <= cp; j++) {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					}
						
						result += kouyaku;
						
						kouyaku = 1;
						
					}
					
				}
			} for(int b = 1; b <= max; b++) {
			
				for(int c= 1; c <= max; c++) {
				
					int ap = a;
					
					int bp = b;
					
					int cp = c;
					
					for(int j= 1; j <= ap && j <= bp && j <= cp; j++) {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					}
						
						result += kouyaku;
						
						kouyaku = 1;
						
					}
					
				} int b = 1; int b = 1; b 1 b <= max b max b++ b++ b {
			
				for(int c= 1; c <= max; c++) {
				
					int ap = a;
					
					int bp = b;
					
					int cp = c;
					
					for(int j= 1; j <= ap && j <= bp && j <= cp; j++) {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					}
						
						result += kouyaku;
						
						kouyaku = 1;
						
					}
					
				} {
			
				for(int c= 1; c <= max; c++) {
				
					int ap = a;
					
					int bp = b;
					
					int cp = c;
					
					for(int j= 1; j <= ap && j <= bp && j <= cp; j++) {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					}
						
						result += kouyaku;
						
						kouyaku = 1;
						
					}
					
				} for(int c= 1; c <= max; c++) {
				
					int ap = a;
					
					int bp = b;
					
					int cp = c;
					
					for(int j= 1; j <= ap && j <= bp && j <= cp; j++) {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					}
						
						result += kouyaku;
						
						kouyaku = 1;
						
					} int c= 1; int c= 1; c 1 c <= max c max c++ c++ c {
				
					int ap = a;
					
					int bp = b;
					
					int cp = c;
					
					for(int j= 1; j <= ap && j <= bp && j <= cp; j++) {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					}
						
						result += kouyaku;
						
						kouyaku = 1;
						
					} {
				
					int ap = a;
					
					int bp = b;
					
					int cp = c;
					
					for(int j= 1; j <= ap && j <= bp && j <= cp; j++) {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					}
						
						result += kouyaku;
						
						kouyaku = 1;
						
					} int ap = a; ap a int bp = b; bp b int cp = c; cp c for(int j= 1; j <= ap && j <= bp && j <= cp; j++) {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					} int j= 1; int j= 1; j 1 j <= ap && j <= bp && j <= cp j <= ap && j <= bp && j <= cp j <= ap j ap j <= bp j bp j <= cp j cp j++ j++ j {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					} {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					} if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							} ap%j == 0 && bp%j ==0 && cp%j == 0 ap%j == 0 && bp%j ==0 && cp%j == 0 ap%j == 0 ap%j ap j 0 bp%j ==0 bp%j bp j 0 cp%j == 0 cp%j cp j 0 {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							} kouyaku *= j kouyaku j ap /= j ap j bp /= j bp j cp /= j cp j j = 1 j 1 result += kouyaku result kouyaku kouyaku = 1 kouyaku 1 sc.close() sc.close sc System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int max = sc.nextInt();
		
		long result = 0;
		
		long kouyaku = 1;
		
		for(int a = 1; a <= max; a++) {
		
			for(int b = 1; b <= max; b++) {
			
				for(int c= 1; c <= max; c++) {
				
					int ap = a;
					
					int bp = b;
					
					int cp = c;
					
					for(int j= 1; j <= ap && j <= bp && j <= cp; j++) {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					}
						
						result += kouyaku;
						
						kouyaku = 1;
						
					}
					
				}
			}
		
						
		
		sc.close();
		
		System.out.println(result);
		
	}
	
} public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int max = sc.nextInt();
		
		long result = 0;
		
		long kouyaku = 1;
		
		for(int a = 1; a <= max; a++) {
		
			for(int b = 1; b <= max; b++) {
			
				for(int c= 1; c <= max; c++) {
				
					int ap = a;
					
					int bp = b;
					
					int cp = c;
					
					for(int j= 1; j <= ap && j <= bp && j <= cp; j++) {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					}
						
						result += kouyaku;
						
						kouyaku = 1;
						
					}
					
				}
			}
		
						
		
		sc.close();
		
		System.out.println(result);
		
	}
	
} Main


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int max = sc.nextInt();
		
		long result = 0;
		
		long kouyaku = 1;
		
		for(int a = 1; a <= max; a++) {
		
			for(int b = 1; b <= max; b++) {
			
				for(int c= 1; c <= max; c++) {
				
					int ap = a;
					
					int bp = b;
					
					int cp = c;
					
					for(int j= 1; j <= ap && j <= bp && j <= cp; j++) {
							
							if(ap%j == 0 && bp%j ==0 && cp%j == 0) {
								
								kouyaku *= j;
								
								ap /= j;
								
								bp /= j;
								
								cp /= j;
								
								j = 1;
								
							}
							
					}
						
						result += kouyaku;
						
						kouyaku = 1;
						
					}
					
				}
			}
		
						
		
		sc.close();
		
		System.out.println(result);
		
	}
	
}
