#include <stdio.h>
#include <math.h>

int fanc(long long a,int n){
return n?(fanc((a*a),n/2)*(n%2?a:1)):1;
}
int main(void){
	int a,b,N=3,K,count;
	long long sum;
	long long del[100001];
	sum = 0;
	scanf("%d",&K);
	for(a=N;0<a;a--){
		count=N/a;
		del[a]=fanc(count,K);
		if(1<count)
			for(b=2;b<=count;b++)
				del[a]=del[a]-del[a*b];
        	sum=sum+a*del[a];
 }
    printf ("%d",sum);
    return 0;
}