## MELE2 - ELEVATOR II

no tags

Edward works as an engineer for Non-trivial Elevators: Engineering, Research and Construction (NEERC). His new task is to design a brand new elevator for a skyscraper with h ﬂoors. Edward has an idée fixe: he thinks that four buttons are enough to control the movement of the elevator. His last proposal suggests the following four buttons:

• Move a ﬂoors up.
• Move b ﬂoors up.
• Move c ﬂoors up.

Initially, the elevator is on the ﬁrst ﬂoor. A passenger uses the ﬁrst three buttons to reach the ﬂoor she needs. If a passenger tries to move a, b or c ﬂoors up and there is no such ﬂoor (she attempts to move higher than the h-th ﬂoor), the elevator doesn’t move. To prove his plan worthy, Edward wants to know how many ﬂoors are actually accessible from the ﬁrst ﬂoor via his elevator. Help him calculate this number.

### Input

The ﬁrst line of the input ﬁle contains one integer h — the height of the skyscraper (1 ≤ h ≤ 10^18). The second line contains three integers a, b and c — the parameters of the buttons (1 ≤ a, b, c ≤ 100000)

### Output

Output one integer number — the number of ﬂoors that are reachable from the ﬁrst ﬂoor.

### Example

```Input 1:
15
4 7 9

Output 1:
9```
```Input 2:
500000
160 96 111

Output 2:
498167```
```Input 3:
987654321987654321
99995 99997 99999

Output 3:
987654319487854318```

 Added by: psetter Date: 2009-02-26 Time limit: 1s Source limit: 50000B Memory limit: 1536MB Cluster: Cube (Intel G860) Languages: All except: C99 ERL JS-RHINO Resource: NEERC 2007–2008