#include int main(void){ int A,B,C,D; int ans; scanf("%d%d%d%d",&A,&B,&C,&D); ans = ((A*B)*C)%D; printf("%d",ans); return 0; }