#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int n,s,perm[10];

int fact(int n){
	if(n==0)return 1;
	return fact(n-1)*n;
}

int main(){
	while(cin>>n>>s){
		for(int i=0;i<10;i++)perm[i]=i;
		int ans=0,wait=0;
		do{
			if(wait){wait--;continue;}
			int sum=0;
			for(int i=1;i<=n;i++)sum+=i*perm[i-1];
			if(sum==s)ans++;
			wait=fact(10-n)-1;
		}while(next_permutation(perm,perm+10));
		cout<<ans<<endl;
	}
}