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