#include #include #include using lint = long long; constexpr lint INF = 1LL << 50; void solve() { std::vector fib{1, 1}; while (fib.back() < INF) { fib.push_back(fib[fib.size() - 1] + fib[fib.size() - 2]); } int m = fib.size(); std::vector xs(5); for (auto& x : xs) std::cin >> x; std::reverse(xs.begin(), xs.end()); int ans = 0; for (int i = 0; i + 5 <= m; ++i) { for (int j = 0; j < 5; ++j) { if (xs[j] != fib[j + i]) break; ans = std::max(ans, j + 1); } } std::cout << ans << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }