#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; typedef pair pcc; typedef pair P; typedef tuple t3; #define rep(i,a) for(ll i = 0;i < a;i++) const ll mod = 1e9+7; unordered_map memo; ll fib(ll key){ if(memo.count(key)) return memo[key]; auto m = fib(key-1) + fib(key-2); memo[key] = m; return m; } int main(void) { vector vs(5); rep(i,5){ cin >> vs[4-i]; } memo[0] = 1; memo[1] = 1; memo[2] = 2; ll key = 1; while(true) { auto f = fib(key); if(f == vs[0]){ ll count = 1; for(int i = 1;i < 5;i++){ if(fib(key+i) == vs[i]) count++; else break; } cout << count << endl; return 0; } else if(f > vs[0]) { cout << 0 << endl; return 0; } key++; } return 0; }