#include #define INF 2000000000000000000 #define ll long long using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll A; cin >> A; ll ans = INF; for (ll i = 1; i <= 60; ++i) { if (A <= pow(2, i)) { ans = i * 2; break; } } for (ll i = 1; i <= 38; ++i) { if (A <= pow(3, i)) { ans = min(ans, i * 3); break; } } for (ll i = 1; i <= 26; ++i) { if (A <= pow(5, i)) { ans = min(ans, i * 5); break; } } for (ll i = 1; i <= 22; ++i) { if (A <= pow(7, i)) { ans = min(ans, i * 7); break; } } cout << ans << "\n"; }