/**
题目:GCD
链接:https://vjudge.net/contest/178455#problem/E
题意:给定整数N,求1<=x,y<=N且Gcd(x,y)为素数的
数对(x,y)有多少对. 1<=N<=10^7 思路:
定义:
f(n)表示gcd(x,y)==n的对数。
F(n)表示n|gcd(x,y)的对数。 枚举n以内的素数p; f(p) = sigma(mu[d/p]*F(d)) (p|d) F(d) = (n/d)*(n/d); N/10*sqrt(N)复杂度。 */
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
typedef long long LL;
#define ms(x,y) memset(x,y,sizeof x)
typedef pair<int, int> P;
const LL INF = 1e10;
const int mod = 1e9 + ;
const int maxn = 1e7 + ;
int prime[maxn], tot, not_prime[maxn];
int mu[maxn], sum[maxn];
void init()
{
mu[] = ;
tot = ;
for(int i = ; i < maxn; i++){
if(!not_prime[i]){
prime[++tot] = i;
mu[i] = -;
}
for(int j = ; prime[j]*i<maxn; j++){
not_prime[prime[j]*i] = ;
if(i%prime[j]==){
mu[prime[j]*i] = ;
break;
}
mu[prime[j]*i] = -mu[i];
}
}
for(int i = ; i < maxn; i++) sum[i] = sum[i-]+mu[i];
}
LL solve(int n)///x在[1,n], y在[1,n],z在[1,n] gcd(x,y,z)=1的对数。
{
LL ans = ;
int last;
for(int i = ; i <= n; i=last+){
last = n/(n/i);
ans += (LL)(sum[last]-sum[i-])*(n/i)*(n/i);
}
return ans;
}
int main()
{
//freopen("in.txt","r",stdin);
int T;
int n;
init();
while(scanf("%d",&n)==)
{
LL ans = ;
for(int i = ; i <= tot&&prime[i]<=n; i++){
ans += solve(n/prime[i]);
//cout<<"prime = "<<prime[i]<<endl;
//cout<<"ans = "<<ans<<endl;
}
printf("%lld\n",ans);
}
return ;
}