//#define _GLIBCXX_DEBUG #include #define rep(i, n) for(int i=0; i; using vs = vector; using vi = vector; using vvi = vector; template using PQ = priority_queue; template using PQG = priority_queue, greater >; const int INF = 0xccccccc; const ll LINF = 0xcccccccccccccccLL; template inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);} template inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);} template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second;} template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second;} #define BASE 3725290298461914062LL #define __BASE 201023764667814403LL #define SIZE 27 #define __SIZE 108 //head ll n; ll dp[__SIZE+1], dpp[__SIZE+1]; ll *now = dp, *pre = dpp; int cnt; void add(int u) { rep(i, __SIZE-u+1) { now[i+u] += pre[i]; } } ll Q(vi z) { memset(pre, 0, sizeof(dp)); cnt = 0; for(int i = SIZE-1; i >= 0; i--) { memset(now, 0, sizeof(dp)); rep(j, z[i]) { now[cnt+j]++; } cnt += z[i]; rep(j, 5) add(j); swap(now, pre); } pre[cnt]++; return pre[SIZE<<1]; } vi Z(ll z) { vi res(SIZE); rep(i, SIZE) { res[i] = z%5; z /= 5; } return res; } int main() { scanf("%lld", &n); printf("%lld\n", Q(Z(n+BASE)) - __BASE); }