#include<stdio.h>
#include <string.h>
int main()
{
unsigned long long n,k,val,fact=1,coeff=0;
char excl[128];
scanf ("%llu %s", &n, excl) ;
k=strlen(excl) ;
while(n-coeff*k>k)
{
val=n-coeff*k;
fact=fact*val;
++coeff;
}
if(n%k)
fact=fact*(n%k);
else fact=fact*k;
printf("%llu",fact);
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGUgPHN0cmluZy5oPgoKaW50IG1haW4oKQp7CiAgICB1bnNpZ25lZCBsb25nIGxvbmcgbixrLHZhbCxmYWN0PTEsY29lZmY9MDsKCiAgICBjaGFyIGV4Y2xbMTI4XTsKCiAgICBzY2FuZiAoIiVsbHUgJXMiLCAmbiwgZXhjbCkgOwoKICAgIGs9c3RybGVuKGV4Y2wpIDsgCgogICAgd2hpbGUobi1jb2VmZiprPmspCiAgICB7CiAgICAgICAgdmFsPW4tY29lZmYqazsKICAgICAgICBmYWN0PWZhY3QqdmFsOwogICAgICAgICsrY29lZmY7CiAgICB9CgoKICAgIGlmKG4laykKICAgICAgICBmYWN0PWZhY3QqKG4layk7CiAgICBlbHNlIGZhY3Q9ZmFjdCprOwoKICAgIHByaW50ZigiJWxsdSIsZmFjdCk7CgogICAgcmV0dXJuIDA7Cn0=