#include using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) #define rep2(i, x, n) for(int i = x; i <= n; i++) #define rep3(i, x, n) for(int i = x; i >= n; i--) #define elif else if #define sp(x) fixed << setprecision(x) #define pb push_back #define eb emplace_back #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() using ll = long long; using ld = long double; using pii = pair; using pil = pair; using pli = pair; using pll = pair; const ll MOD = 1e9+7; //const ll MOD = 998244353; const int inf = (1<<30)-1; const ll INF = (1LL<<60)-1; const ld EPS = 1e-10; template bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;}; template bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;}; ll pw[27]; ll solve(ll n){ int dig[27]; ll memo = n; rep(i, 27){ dig[i] = memo%5, memo /= 5; } rep(i, 27) cout << dig[i] << ' '; cout << endl; ll dp[28][150][2]; rep(i, 28) rep(j, 150) rep(k, 2) dp[i][j][k] = 0; dp[27][0][0] = 1; rep3(i, 26, 0){ rep(j, 150){ rep(k, 5){ dp[i][j+k][1] += dp[i+1][j][1]; } dp[i][j+dig[i]][0] += dp[i+1][j][0]; rep(k, dig[i]){ dp[i][j+k][1] += dp[i+1][j][0]; } } } return dp[0][54][0]+dp[0][54][1]; } int main(){ ll N; cin >> N; pw[0] = 1; rep(i, 26) pw[i+1] = pw[i]*5; ll sum = 0; rep(i, 27) sum += pw[i]; sum *= 2; cout << solve(sum+N)-solve(sum) << endl; }