# include # include # include # include # include # include # include # include using namespace std; # define repl(i, a, b) for(int i=(int)(a);i<(int)(b);i++) # define rep(i, n) repl(i, 0, n) typedef long long ll; int main(){ ll a, b, c, d; cin >> a >> b >> c >> d; cout << a*b*c%d << endl; return 0; }