#include <iostream>

using namespace std;

int n, s, num[10], pattern;
void search(int th) {
  if (th == n) {
    int sum = 0;
    for (int i = 0; i < n; i++)
      sum += num[i] * (i+1);
    if (s == sum) {

      for (int j = 0; j < n; j++)
        cout << num[j];
      cout << endl;

      pattern++;
    }
  } else {
    bool hoge = false;
    int piyo;
    for (int i = 0; i < 10; i++) {
      piyo = 0;
      for (int j = 0; j < th; j++) {
        piyo += num[j] * (j+1);
        if (num[j] == i) {
          hoge = true;
          break;
        }
      }
      if (hoge) {
        hoge = false;
        continue;
      } else if (piyo > s) {
        return;
      }
      num[th] = i;
      search(th + 1);
    }
  }
}

int main(int argc, char *argv[]) {
  while (cin >> n >> s) {
    pattern = 0;
    search(0);
    cout << pattern << endl;
  }
  return 0;
}