// macros #include #include #include #include #include using namespace std; typedef long long ll; typedef pair pii; #define LLINF 1000000000000000000LL #define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define debug(a) cout << "L(" << __LINE__ << "):" << #a << ":" << a << endl; // problems limits #define MAX_N 10000 // Variables ll A,B,C,D; // problems input void input() { cin >> A >> B >> C >> D; } // problems main void solve() { ll ans = 0; ans = (A*B)%D; ans = (ans*C)%D; cout << ans << endl; } int main() { ios::sync_with_stdio(false); input(); solve(); }