#define _USE_MATH_DEFINES #include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() using ll = long long; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-8; const int MOD = 1000000007; // const int MOD = 998244353; const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1}; const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1}; template inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; } template inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(20); } } iosetup; int main() { const int X = 26; ll n; cin >> n; ++n; vector five(X, 0); ll tmp = n; REP(i, X) { five[i] = tmp % 5; tmp /= 5; } vector dp(X + 1, vector(X * 2 + 1, vector(X * 2 + 1, vector(2, vector(2, 0LL))))); dp[0][0][0][false][false] = 1; REP(i, X) REP(j, X * 2 + 1) REP(k, X * 2 + 1) REP(l, 2) REP(m, 2) { REP(w, 5) { REP(a, 3) REP(b, 3) { if (j + a > X * 2 || k + b > X * 2 || a + b >= 3 || (a == 1 && b == 1)) continue; int val = w + m + a; if (val % 5 != b) continue; int nx_l = w < five[i] || (w == five[i] && l); dp[i + 1][j + a][k + b][nx_l][val >= 5] += dp[i][j][k][l][m]; } } } ll ans = 0; FOR(j, 1, X * 2 + 1) ans += dp[X][j][j][true][false] + dp[X][j][j - 1][true][true]; cout << ans << '\n'; return 0; }