#include <iostream>

using namespace std;

int data[10];
int sumN = 0;

void func(int n,int limit,int ans,int sum){
	if(n == limit){
		if(sum == ans)sumN++;
		return;
	}
	for(int i=0;i<10;i++){
		int tmpSum = sum + i*(n+1);
		int state = 0;
		for(int j=0;j<n;j++){
			if(data[j] == i){
				state = 1;
				break;
			}
		}
		if(state != 1)data[n] = i,func(n+1,limit,ans,tmpSum);
	}
}



int main(){
	int n,s;
	while(cin>>n){
		cin>>s;
		sumN=0;
		func(0,n,s,0);
		cout<<sumN<<endl;
	}
	return 0;
}

/*
Sample Input
3 10
3 1
Output for the Sample Input
8
0
*/