#include using namespace std; const long long INF = 10000000000000; int main(){ vector A; A.push_back(1); A.push_back(4); A.push_back(18); while (A.back() < INF){ long long x = A.back(); long long y = A[A.size() - 2]; A.push_back(x * 8 - y * 17); } long long N; cin >> N; int M = 0; for (int i = 0; i < A.size(); i++){ if (A[i] < N){ M++; } } cout << N - M << endl; }