#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; i <= (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define srep(i,s,t) for (int i = s; i < t; ++i) using namespace std; typedef long long int ll; typedef pair P; typedef vector vi; typedef vector vvi; typedef vector vl; typedef vector

vp; #define dame { puts("-1"); return 0;} #define yn {puts("Yes");}else{puts("No");} /* Max_Prime以下の素数をprimes[]に格納 */ const int Max_Prime = 1000000; vector tmp_primes; vector primes; void PrimeInit() { rep(i,Max_Prime-1){ tmp_primes.push_back(i+2); } int rem = Max_Prime - 1; int count = 0; while(rem>0){ if(tmp_primes[0]*tmp_primes[0] > Max_Prime){ rep(i,rem){ primes.push_back(tmp_primes[i]); count++; } break; } primes.push_back(tmp_primes[0]); count++; int count2 = 0; srep(i,1,rem){ if(tmp_primes[i] % primes[count-1] != 0){ tmp_primes[count2] = tmp_primes[i]; count2++; } } rem = count2; } } int main(){ PrimeInit(); int n; cin >> n; int ans = 0; rep(i,primes.size()){ if(primes[i] * primes[i] > n)break; if(binary_search(primes.begin(), primes.end(), primes[i] * primes[i] - 2))ans++; } if(ans>0)ans = ans*2-1; cout << ans << endl; return 0; }