#include int main(void) { long int A, B, C, D; scanf("%ld %ld %ld %ld", &A, &B, &C, &D); printf("%ld\n", (A * B * C) % D); return 0; }