#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
long long ans;
int n,m;
long long Calc(int n,int k){
long long ret=1;
for(int i=1;i<=n;i++)ret*=i;
for(int i=1;i<=k;i++)ret/=i;
for(int i=1;i<=n-k;i++)ret/=i;
return ret;
}
int main(){
freopen("boxball.in","r",stdin);
freopen("boxball.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i=m;i>=1;i--){
long long ret=1;
for(int j=1;j<=n;j++)
ret*=i;
if((m-i+1)&1)
ans+=ret*Calc(m,i);
else
ans-=ret*Calc(m,i);
}
printf("%lld\n",ans);
return 0;
}