Execution time limit is 1 second

Runtime memory usage limit is 256 megabytes

Due to recent layoffs in the IT sector, Petro decided to evaluate his productivity. Petro is a consistent worker who completes one task per day. However, he works a specific schedule, working $a$ days followed by $b$ days off (i.e. he works for $a$ consecutive working days and then takes $b$ days off).

Petro, who is a proponent of random rest theory, doesn't work every $n$th day, regardless of whether it is a working day or a day off. However, to compensate for this, he works twice as effectively every $m$th day (if he is working), meaning he completes two tasks per day instead of just one.

Evaluate Petro's monthly productivity (number of tasks he completes) assuming the month has $k$ days and starts on the first working day.

The input consists of five integers $a,b,n,m,$ and $k$ $(1≤a,b,n,m,k≤10_{5})$.

Output a single integer - Petro's productivity.

Input #1

Answer #1

Input #2

Answer #2

In the first example, Petro works for the first three days, but doesn't work on the third day because $n=3$. The fourth day is scheduled as a day off and the fifth day is a working day for Petro. Since $m=10$ and there are only $5$ days in the month, Petro doesn't work twice as effectively for any day. Therefore, Petro works for three days at a regular pace, completing three tasks.

In the second example, Petro works for $10$ days and takes $2$ days off in a cycle, and takes an additional random day off. Since $k=5$, all the days in the month are working days according to the cycle, as the month ends before there is a scheduled day off. We also know that $m=3$, so every third day is a day of double efficiency. Petro works at a regular pace and completes two tasks on the first and second days, works twice as efficiently and completes two tasks on the third day, then works at a regular pace and completes two tasks on the fourth and fifth days. Therefore, Petro completes $2+2+2=6$ tasks this month.