#include <bits/stdc++.h>

using namespace std;

using ll = long long;

vector<ll> getdiv(ll n) {
    ll i = 1;
    vector<ll> ans;
    while (i * i <= n) {
        if (n % i == 0) {
            ans.push_back(i);
            if (i * i != n) {
                ans.push_back(n/ i);
            }
        }
        i++;
    }
    return ans;
}

int main() {
    ll x, y; cin >> x >> y;
    x = 1 << x;
    vector<ll> d = getdiv(x);
    ll val = 0;
    ll all = 0;
    for(int i = 0; i < (1 << d.size()); i++) {
        ll a = x;
        bitset<50> p = i;
        for(int j = 0; j < d.size(); j++) {
            if(p[j]) a ^= d[j];
        }
        all++;
        if (__builtin_popcount(a) == y) val++;
    }
    cout << val % (ll)(1e9 + 7);
}
