#include using namespace std; using ll = long long; #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define all(p) (p).begin(),(p).end() ll solve3(ll N, ll M){ assert(M <= 60); vector f(M + 5); f[0] = 1, f[1] = 1; for (int i = 2; i <= M + 4; i++){ f[i] = f[i - 1] + f[i - 2]; } ll ans = 0; rep(l, 0, M + 2) rep(r, l + 1, M + 5){ ll sum = 0; rep(k, l, r) sum += f[k]; if (sum <= f[M - 1] && sum % N == 0) ans++; } return ans; } int main(){ int N, M; cin >> N >> M; cout << solve3(N, M) << "\n"; }