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