#include <stdio.h>
#include <stdlib.h>

int main(void){
	int K=200;
	//scanf("%d",&K);

	int sum=0;
	int h=0;
	int gcd,gcd_i,gcd_j,gcd_k = 0;

	for(int i=1; i<=K; i++){
	    for(int j=1; j<=K; j++){
	        for(int k=1; k<=K; k++){
	           	//printf("ijk = %d%d%d\n",i,j,k);
	           	gcd=0;
           	    int a=i,b=j,c=k;
           	    int temp=0;
           	    a = a%i;
           	    b = b%i;
           	    c = c%i;
           	    //printf("%d%d%d\n",a,b,c);
           	   	if(a==0&&b==0&&c==0){
           	    	//temp=k;
           	    	gcd_i = i;
           		}
           		// if(temp>gcd){
           		//     gcd = temp;
           		// }
           		//printf("gcd = %d\n",gcd);
	           	sum+=gcd;
	           	a=i,b=j,c=k;
	           	a = a%j;
           	    b = b%j;
           	    c = c%j;
           	    //printf("%d%d%d\n",a,b,c);
           	   	if(a==0&&b==0&&c==0){
           	    	//temp=k;
           	    	gcd_j = j;
           		}
           		// if(temp>gcd){
           		//     gcd = temp;
           		// }
           		//printf("gcd = %d\n",gcd);
	           	sum+=gcd;
	           	a=i,b=j,c=k;
	           	a = a%k;
           	    b = b%k;
           	    c = c%k;
           	    //printf("%d%d%d\n",a,b,c);
           	   	if(a==0&&b==0&&c==0){
           	    	//temp=k;
           	    	gcd_k = k;
           		}
           		if(gcd_j>gcd_j){
           			if(gcd_j>gcd_k){
           			    gcd = gcd_i;
           			}
           			else{
           				gcd = gcd_k;
           			}
           		}
           		else if(gcd_j > gcd_k){
           		    gcd = gcd_j;
           		}
           		else{
           		 gcd = gcd_k; 
           		}
           		//printf("gcd = %d\n",gcd);
	           	sum+=gcd;
	           	//printf("sum =  %d\n\n",sum);
	    	}
	    }
	}

	printf("%d\n",sum);

	return 0;


}