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