#include <iostream>

int used[10];

void solve(const int& sum,
           const int& s, int limit,
           long long int& cnt) {
    
    if (limit == 0) {
        if (sum == s) {
            ++cnt;
        }

        return;
    }

    for (int i = 9; i >= 0; --i) {
        if (used[i] == 0) {
            int est_sum = 9 * (limit - 1) * (limit - 1);
            if (est_sum + sum + i * limit < s) {
                break;
            }

            used[i] = 1;
            solve(sum + i * limit,
                  s, limit - 1,
                  cnt);
            used[i] = 0;
        }
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int s, n;
    while (std::cin >> n >> s) {
        long long int cnt = 0;
        solve(0, s, n, cnt);

        std::cout << cnt << std::endl;
    }

    return 0;
}