#include #include #include #include int cmp(const void *a,const void *b){ if(*(int*)a>*(int*)b){return 1;} else if(*(int*)a<*(int*)b){return -1;} else {return 0;} } int min(int a,int b){ if(a>=b){return b;} return a; } //cww int main(void){ long long int a,b,c,d; int res; scanf("%lld %lld %lld %lld",&a,&b,&c,&d); res=a*b%d; res=res*c%d; printf("%d\n",res); }