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