#include <stdio.h>

int main() {
	int k;
	unsigned long long gcd = 0;
	scanf("%d", &k);/////////_s
	for (int a = 1; a <= k; a++) {
		for (int b = 1; b <= k; b++) {
			for (int c = 1; c <= k; c++) {
				for (int i = 1; i < 205; i++) {
					if (a%i != 0 || b % i != 0 || c % i != 0) {
						gcd += (i - 1);
						break;
					}
				}
			}
		}		
	}
	printf("%llu", gcd);
	return 0;
}