eolymp
bolt
Try our new interface for solving problems
Problems

Competitors’ quantity of olimpia

Competitors’ quantity of olimpia

Time limit 1 second
Memory limit 64 MiB

How we know for question how many pupils he has Greek scientist Pifagor answer: “One half of my pupils learn math, the fourth parts learns nature, the seventh part spend time in thinking, the last part is three girls”. For question “How many competitors’ quantity of olimpiad from computer science registered?”. The secretary of olimpiad answer like Pifagor: "K part of boys start solves first problem, M part – start solves sec-ond problem and N part – start solves third problem. In that time D competitors’ decide a problem: "How to start?". Your task is find the competitors’ quantity of olimpiad S, or write -1, if secretary wrongs in his message.

Input In a single line through the gap in the number of K, N, M, D. 1K, N, M, D1000. Output Output the number of participants Olympiad S, or -1 if the Secretary was mistaken in his report.

Examples

Input example #1
2 4 7 3
Output example #1
28
Author Prysiazhnyuk A.