a, b, c, d = map(float, raw_input().split()) print a * b * c % d