#include #include "math.h" #include using namespace std; int main() { long long A, B, C, D; cin >> A >> B >> C >> D; long long sum = (A % D) * (B % D) * (C % D) % D; cout << sum << endl; return 0; }