let input:[Int] = readLine()!.split(separator: " ").map{Int($0)!} let output = (input[0] * input[1] * input[2]) % input[3] print(output)