#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
typedef long long ll;

int memo[11][1000]; // memo[n][s]には最終的にn個の数字を使って和がsのものを何通りで作れるかが入る

void dfs(vector<int> used, int now) {
    cout << "dfs:" << used.size() << endl;
    int num = used.size() + 1;
    if (num == 11) return;
    for (int i = 0; i < 10; i++) {
        if (find(used.begin(), used.end(), i) == used.end()) {
            int next = now + i * num;
            memo[num][next]++;
            used.push_back(i);
            dfs(used, next);
            used.pop_back();
        }
    }
}

int main(void) {
    vector<int> none;
    dfs(none, 0);
    cout << "dfs end" << endl;
    int n, s;
    while (cin >> n >> s) {
        cout << memo[n][s] << endl;
    }
    return 0;
}