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