#include int main() { int a,b,c,d,x; scanf("%d %d %d %d",&a,&b,&c,&d); x=a*b*c%d; printf("%d\n",x); return 0; }