import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
public static int cmmdc(int a, int b){
int t;
while (b != 0)
{
t = b;
b = a % b;
a = t;
}
return a;
}
public static boolean isIreductible(int x, int y){
boolean toReturn = false;
if(cmmdc(x,y) == 1)
toReturn = true;
else toReturn = false;
return toReturn;
}
public static int solution(int n){
int nr = 0;
for(int i=1; i<=n; ++i)
for(int j=1; j<=n; ++j)
if(isIreductible(i,j))
++nr;
return nr;
}
public static void main(String args[]) throws FileNotFoundException{
Scanner sc = new Scanner(new FileInputStream("fractii.in"));
int n = sc.nextInt();
PrintWriter writer = new PrintWriter("fractii.out");
writer.write(""+solution(n));
writer.close();
sc.close();
}
}