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