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