Олимпиадный тренинг

Задача 27173. BIRDS


Задача

Темы:
Vsevolod Yurievich got a job as a security guard at a warehouse. The work is monotonous, and out of boredom Vsevolod Yuryevich counts crows and other birds flying past the security booth. Over the years, he discovered the following pattern. Ravens fly alone, starting at 8:00 am with a frequency of P1 minutes, and after 8:00 pm they stop flying. Ducks fly in flocks of N pieces, starting from 10:00 am, with a frequency of P2 minutes, and stop flying after 5:00 pm. Pigeons fly singly from 7:00 am to 8:00 pm with a frequency of P3 minutes. Three times a day, Vsevolod Yurievich has to take a break from his work for exactly an hour and a half in order to take goods to the warehouse. Reception starts promptly at 11:00, 15:00 and 17:00. How many birds (M) will Vsevolod Yurievich count per shift if the shift starts at 6:00 am and ends at 6:00 am the next day?

In all time intervals, the left end is included in it, but the right end is not. For example, one of the acceptances starts at 11:00 and Vsevolod Yuryevich does not count birds flying from 11:00 to 12:29 inclusive, but counts birds flying at 12:30.

Input data format
The line contains 4 positive integers not exceeding 10000 each: P1, P2, N, P3, separated by a space.
Output data format
The single line contains an integer M – the number of birds that Vsevolod Yurievich will count per shift under the specified entry conditions.

Enter Output
P1 P2 N P3 M
23 57 5 7 123