#include #include using namespace std; using ll=long long; using ld=long double; using vll=vector; using pll=pair; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll A,B,C,D; cin>>A>>B>>C>>D; A%=D;B%=D;C%=D; cout<<((A*B)%D*C)%D<