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