#include <bits/stdc++.h>
using namespace std;
#define io(x) if(fopen(x".INP", "r")){freopen(x".INP","r",stdin);freopen(x".OUT","w",stdout);}
#define uf(i, a, b) for (int i = (a); i <= (b); i++)
#define df(i, a, b) for (int i = (a); i >= (b); i--)
#define rep(i, n) for (int i = 1; i <= (n); i++)
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define ms(a, v) memset(a, v, sizeof(a))
#define bit(i, x) ((x >> i) & 1)
template <class T> bool maximize(T &a, const T &b){ return (a < b ? a = b, 1 : 0); }
template <class T> bool minimize(T &a, const T &b){ return (a > b ? a = b, 1 : 0); }
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
// End of template
const int MOD = 1e9+7;
const int maxn = 3e6+5;
const int inf = 2e9+123;
int n;
vi p;
bool prime[maxn];
void sieve(int n, ll &res){
int super = 3*n;
rep(i, super-1) prime[i] = 1;
for (int i = 2; i*i < super; i++){
if (!prime[i]) continue;
for (int j = i*i; j < super; j += i) prime[j] = 0;
}
uf(i, 3, super-1) if (prime[i]){
res += i/2;
res -= ((i/2 - n) > 0 ? (i/2 - n) : 0);
res -= ((i - n - 1) / 2 > 0 ? (i - n - 1) / 2 : 0);
// cout << i << ' ' << res << '\n';
}
}
void solve(){
cin >> n;
ll res = 0;
sieve(n, res);
cout << res;
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
io("TEST");
// freopen("TEST.INP","r",stdin);
// freopen("TEST.ANS","w",stdout);
int numTest;
numTest = 1;
// cin >> numTest;
while(numTest--){
solve();
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgaW8oeCkgaWYoZm9wZW4oeCIuSU5QIiwgInIiKSl7ZnJlb3Blbih4Ii5JTlAiLCJyIixzdGRpbik7ZnJlb3Blbih4Ii5PVVQiLCJ3IixzdGRvdXQpO30KI2RlZmluZSB1ZihpLCBhLCBiKSBmb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