#include #define FastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false)) #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; void solve() { long long int a, b, c, d; cin >> a >> b >> c >> d; cout << (a % d) * (b % d) * (c % d) % d << '\n'; } int main() { FastIO; solve(); return 0; }