#include using namespace std; using ll = long long; template using vec = vector; template using vvec = vector>; ll dp[40][100][100][2][2] = {}; int main(){ cin.tie(0); ios::sync_with_stdio(false); ll N; cin >> N; ll five = 1; while(5*five<=N) five *= 5; string S = ""; ll n = N; while(five){ ll a = n/five; S += (char) '0'+a; n -= five*a; five /= 5; } cerr << S << "\n"; int M = S.size(); int A = 60; dp[0][0][0][0][0] = 1; dp[0][1][0][0][1] = 1; for(int i=0;ix) continue; for(int a=0;a<3;a++) for(int b=0;b<3;b++){ if(a+b>2) continue; if(a==b && a>0) continue; int nl = l+a,nr = r+b; int nj = 0; if(a+5*j-b==n) nj = 0; else if(a+5*j-b==n+1) nj = 1; else continue; dp[i+1][nl][nr][nk][nj] += dp[i][l][r][k][j]; } } } ll ans = 0; for(int i=0;i