## NEERC '07 Northern E - Elevator

View as PDF

Points: 17
Time limit: 2.0s
Memory limit: 64M

Problem type

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 floors.

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 floors up.
• Move floors up.
• Move floors up.

Initially, the elevator is on the first floor. A passenger uses the first three buttons to reach the floor she needs. If a passenger tries to move , or floors up and there is no such floor (she attempts to move higher than the -th floor), the elevator doesn't move.

To prove his plan worthy, Edward wants to know how many floors are actually accessible from the first floor via his elevator. Help him calculate this number.

#### Input Specification

The first line of the input file contains one integer — the height of the skyscraper . The second line contains three integers , and — the parameters of the buttons .

#### Output Specification

Output one integer number — the number of floors that are reachable from the first floor.

#### Sample Input

15
4 7 9

#### Sample Output

9