#include <iostream>
#include <vector>
using namespace std;
// Hàm tạo sàng Eratosthenes để tìm tất cả các số nguyên tố <= max_n
vector<bool> sieve(int max_n) {
vector<bool> is_prime(max_n + 1, true);
is_prime[0] = is_prime[1] = false;
for (int i = 2; i * i <= max_n; i++) {
if (is_prime[i]) {
for (int j = i * i; j <= max_n; j += i) {
is_prime[j] = false;
}
}
}
return is_prime;
}
int main() {
int n;
cin >> n;
// Tạo sàng Eratosthenes cho các số <= 2 * n
vector<bool> is_prime = sieve(2 * n);
// Mảng lưu giá trị g(k) cho k = 2, ..., n
vector<int> g(n + 1, 0);
// Tính g(k) trước
for (int k = 2; k <= n; k++) {
int target = 2 * k;
for (int p = 2; p <= target / 2; p++) {
if (is_prime[p] && is_prime[target - p]) {
g[k]++;
}
}
}
// Tính f(n) bằng cách cộng dồn g(k)
int fn = 0;
for (int k = 2; k <= n; k++) {
fn += g[k];
}
cout << fn << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKLy8gSMOgbSB04bqhbyBzw6BuZyBFcmF0b3N0aGVuZXMgxJHhu4MgdMOsbSB04bqldCBj4bqjIGPDoWMgc+G7kSBuZ3V5w6puIHThu5EgPD0gbWF4X24KdmVjdG9yPGJvb2w+IHNpZXZlKGludCBtYXhfbikgewogICAgdmVjdG9yPGJvb2w+IGlzX3ByaW1lKG1heF9uICsgMSwgdHJ1ZSk7CiAgICBpc19wcmltZVswXSA9IGlzX3ByaW1lWzFdID0gZmFsc2U7CiAgICBmb3IgKGludCBpID0gMjsgaSAqIGkgPD0gbWF4X247IGkrKykgewogICAgICAgIGlmIChpc19wcmltZVtpXSkgewogICAgICAgICAgICBmb3IgKGludCBqID0gaSAqIGk7IGogPD0gbWF4X247IGogKz0gaSkgewogICAgICAgICAgICAgICAgaXNfcHJpbWVbal0gPSBmYWxzZTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIHJldHVybiBpc19wcmltZTsKfQoKaW50IG1haW4oKSB7CiAgICBpbnQgbjsKICAgIGNpbiA+PiBuOwoKICAgIC8vIFThuqFvIHPDoG5nIEVyYXRvc3RoZW5lcyBjaG8gY8OhYyBz4buRIDw9IDIgKiBuCiAgICB2ZWN0b3I8Ym9vbD4gaXNfcHJpbWUgPSBzaWV2ZSgyICogbik7CgogICAgLy8gTeG6o25nIGzGsHUgZ2nDoSB0cuG7iyBnKGspIGNobyBrID0gMiwgLi4uLCBuCiAgICB2ZWN0b3I8aW50PiBnKG4gKyAxLCAwKTsKCiAgICAvLyBUw61uaCBnKGspIHRyxrDhu5tjCiAgICBmb3IgKGludCBrID0gMjsgayA8PSBuOyBrKyspIHsKICAgICAgICBpbnQgdGFyZ2V0ID0gMiAqIGs7CiAgICAgICAgZm9yIChpbnQgcCA9IDI7IHAgPD0gdGFyZ2V0IC8gMjsgcCsrKSB7CiAgICAgICAgICAgIGlmIChpc19wcmltZVtwXSAmJiBpc19wcmltZVt0YXJnZXQgLSBwXSkgewogICAgICAgICAgICAgICAgZ1trXSsrOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQoKICAgIC8vIFTDrW5oIGYobikgYuG6sW5nIGPDoWNoIGPhu5luZyBk4buTbiBnKGspCiAgICBpbnQgZm4gPSAwOwogICAgZm9yIChpbnQgayA9IDI7IGsgPD0gbjsgaysrKSB7CiAgICAgICAgZm4gKz0gZ1trXTsKICAgIH0KCiAgICBjb3V0IDw8IGZuIDw8IGVuZGw7CiAgICByZXR1cm4gMDsKfQo=