import java.io.*; import java.util.*; import java.util.stream.*; import static java.lang.Math.*; public class Main { Integer[] conv(long x, int base) { List v = new ArrayList<>(); while(x != 0) { int rem = (int)(x % base); if(rem > base / 2) { rem -= base; } v.add(rem); x -= rem; x /= base; } Collections.reverse(v); return v.toArray(new Integer[0]); } private long f(long x) { Integer[] a = conv(x, 5); int n = a.length; // dp[未満フラグ][先行ゼロを抜けたか][荷物側の分銅数][反対側の分銅数] := パターン数 long[][][][] dp = new long[2][2][n+1][n+1]; dp[0][0][0][0] = 1; for(int i=0; i 0 ? 1 : 0, ncntM = cntM + (d < 0 ? -d : 0), ncntP = cntP + (d > 0 ? d : 0); if(ncntM > n) { continue; } if(ncntP > n) { continue; } ndp[nless][n_nuke0][ncntM][ncntP] += dp[less][nuke0][cntM][cntP]; } } } } } dp = ndp; } long res = 0; for(int less=0; less<2; ++less) { for(int nuke0=0; nuke0<2; ++nuke0) { for(int cnt=1; cnt<=n; ++cnt) { res += dp[less][nuke0][cnt][cnt]; } } } return res; } private void solve() { Scanner sc = new Scanner(System.in); long N = sc.nextLong(); long res = f(N); System.out.println(res); } public static void main(String[] args) { new Main().solve(); } }