#include #include #include #include using namespace std; unsigned long long a, b,c,d; int main() { cin >> a >> b >> c >> d; a = a%d; b = b%d; c = c%d; long long d = (a*b)%d; cout << (d*c)%d << endl; return 0; }