Elevator - MarisaOJ: Marisa Online Judge

Elevator

Time limit: 1000 ms
Memory limit: 256 MB
You are in an elevator of a skyscraper with $n$ floors. The elevator has four buttons - Go down to the first floor. - Go up by $A$ floors. - Go up by $B$ floors. - Go up by $C$ floors. You have observed that there are certain floors that cannot be reached from the first floor. Your goal is to determine the count of floors that can be reached from the first floor. ### Input - A single line contains four integers $n, A, B, C$. ### Output - Print an integer, the number of reachable floors. ### Constraints - $1 \le n \le 10^{18}$. - $1 \le A, B, C \le 10^5$. ### Example Input: ``` 10 2 6 9 ``` Output: ``` 6 ```