def f(a,b): c=[0]*L for i in range(L): for j in range(L): c[(i+j)%L]+=a[i]*b[j] c[(i+j)%L]%=mod return c N,M,L,K,mod=map(int,input().split()) ans=[0]*L ans[0]=1 tmp=[0]*L tmp[0]=1 tmp[1%L]=M for i in range(60): if (N>i)&1: ans=f(ans,tmp) tmp=f(tmp,tmp) print(ans[K])