/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
#include <fstream>
using namespace std;
bool np[1000000];
int main()
{
int n,i,j;
ifstream fin ("fractii.in");
fin >>n;
fin.close();
for (i=2;i<=n/2;i++)
if(np[i]==0)
for(j=2*i;j<=n;j+=i)
np[j]=1;
long long int s=1;
int fi;
for (i=2;i<=n;i++)
{
if (np[i]==0)
s+=2*(i-1);
else
{
fi=i;
if(i%2==0)
fi/=2;
for (j=3;j<i;j+=2)
if (np[j]==0 and i%j==0)
{
fi/=j;
fi*=(j-1);
}
s+=2*fi;
}
}
ofstream fout ("fractii.out");
fout <<s;
fout.close();
return 0;
}