#include <bits/stdc++.h>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    assert(1 <= n && n <= 1000000);

    vector<int> r(n + 1);
    for(int i = 0; i <= n; i++){
        r[i] = i;
    }
    for(int i = 2; i <= n; i++){
        if(r[i] != i) continue;
        for(int j = i; j <= n; j += i){
            r[j] -= r[j] / i;
        }
    }

    long long ans = 0;
    for(int y = 1; y <= n; y++){
        ans += ((n / y) - 1) * (r[y] - 1);
    }
    cout << ans << endl; 
}