Competitors’ quantity of the Olympiad#43

Competitors’ quantity of the Olympiad

1 second
64 megabytes
Very easy

As is well known, when asked about the number of his disciples, the ancient Greek scholar Pythagoras replied as follows: Half of my disciples study mathematics, a quarter study nature, a seventh devote themselves to silent contemplation, and the remainder are 3 maidens.

When asked, "How many participants are registered for the informatics olympiad?", the olympiad secretary answers in Pythagorean style: The -th part of the participants started the first problem, the -th part started the second, the -th part started the third, and another participants are busy with the "Where to begin?" problem. Your task is to determine the number of olympiad participants , or output -1 if the secretary made a mistake.

Input

A single line contains four integers , , , (1 \leq k, m, n, d \leq 1000), separated by spaces.

Output

Output the number of olympiad participants , or -1 if the secretary made a mistake.

Examples

Example 1

Loading
Loading