import decimal a,b,c,d = map(decimal.Decimal, input().split(' ')) print(a * b * c % d)