Some people believe that every person's life consists of three cycles, starting from the moment of their birth. These cycles are physical, emotional, and intellectual activity cycles, with periods of , , and days, respectively. Each cycle has only one peak, during which the person is most active in that aspect. Since all three cycles have different periods, their peaks usually do not coincide.
A psychic wants to quickly determine, for any person, the next day when all three peaks will coincide. For each cycle, you are given the day (counted from the beginning of the year) when the last peak occurred for that type of activity (this is not necessarily the first peak of the year). You are also given the day (also from the beginning of the year) on which this person visited the psychic. Your task is to determine, starting from the day of the visit (not including the visit day itself), the minimal number of days until all three types of activities simultaneously reach their peak. If such a "triple peak" occurs on the day of the visit, you must find the next occurrence of a "triple peak" day.
The input contains four integers: , , , , separated by spaces. , , are the days (from the start of the year) when the last peaks occurred for the physical, emotional, and intellectual cycles, respectively. is the day of the visit (also from the start of the year; may be less than any of , , or ). All numbers are positive and do not exceed . It is guaranteed that the next "triple peak" will occur within days after the visit day.
Print one integer — the number of days after the visit until the next "triple peak" of activity.
Ejemplo 1