#include using namespace std; /////////////////// メイン /////////////////// int main () { //////////////////// 入力 //////////////////// int a, b, c, d; cin >> a >> b >> c >> d; //////////////// 出力変数定義 //////////////// int result = 0; //////////////////// 処理 //////////////////// result = (((1LL*a*b)%d)*c)%d; //////////////////// 出力 //////////////////// cout << result << endl; //////////////////// 終了 //////////////////// return 0; }