#include #define THR 300000 long long memo[201][THR + 1]; long long recursion(int N, int K) { if (memo[N][K] >= 0) return memo[N][K]; else if (N == 1) { if (K >= 1) memo[N][K] = 2; else memo[N][K] = 0; return memo[N][K]; } if (K >= N) memo[N][K] = recursion(N - 1, K) + recursion(N - 1, K / N); else memo[N][K] = recursion(N - 1, K); return memo[N][K]; } long long DFS(int N, long long K) { if (N == 1) return (K >= 1)? 2: 0; else if (K <= THR) return recursion(N, (int)K); else return DFS(N - 1, K) + DFS(N - 1, K / N); } int main() { int i, j, N; long long K; scanf("%d %lld\n", &N, &K); for (i = 1; i <= N; i++) for (j = 1, memo[i][0] = 0; j <= THR; j++) memo[i][j] = -1; printf("%lld\n", DFS(N, K) - 1); fflush(stdout); return 0; }