#include using namespace std; typedef long long LL; const int POW2 = 31; const int FERMAT = 5; int main() { // 1. 入力情報取得. LL A; cin >> A; // 2. フェルマー素数. // -> 4294967297 は, 素数でないとのこと. // https://ja.wikipedia.org/wiki/フェルマー数 LL f[FERMAT] = {3, 5, 17, 257, 65537}; // 3. 作図可能性は, (2 の べき乗) × フェルマー素数 の形とのこと. // https://ja.wikipedia.org/wiki/定規とコンパスによる作図 LL pow2[POW2] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824}; // for(int i = 0; i < 31; i++) cout << (1 << i) << endl; // 4. 集計作業. // -> A = 1000000000 だと, 3, 4, 5, 6, 8, ..., // 808464432, 855638016, 855651072, 858980352, 858993459 の 456個 を出力確認できた. int ans = 0; for(int i = 0; i < 32; i++){ // 2-1. i を 2進数表記. stringstream ss; ss << static_cast>(i); string bit = ss.str(); // cout << bit << endl; // 2-2. 各フェルマー素数について, 以下のルールで読み替える. // bit の 各桁が 1 なら, フェルマー素数を使用. // bit の 各桁が 0 なら, フェルマー素数を使用しない for(int j = 0; j < POW2; j++){ LL total = pow2[j]; for(int d = 0; d < FERMAT; d++){ int b = bit[d] - '0'; if(b != 0) total *= b * f[d]; } if(total >= 3 && total <= A){ ans++; // cout << total << endl; } } } // 5. 後処理. cout << ans << endl; return 0; }