#include using namespace std; using Int = long long; //INSERT ABOVE HERE signed main(){ Int a,b,c,d; cin>>a>>b>>c>>d; Int s=a*b%d*c%d; cout<