#t278. 火车上的人数
火车上的人数
Number of People on the Train
Problem Background
Special for beginners, ^_^
Problem Description
A train departs from the starting station (called station ) with people boarding at station . It then arrives at station , where some people board and some alight, but the number boarding equals the number alighting, so when the train leaves station (i.e. before arriving at station ) the number of people on board remains .
From station onward (including station ), the boarding and alighting follow a pattern: the number boarding at each station equals the sum of the numbers that boarded at the previous two stations, and the number alighting equals the number that boarded at the previous station. This holds up to the station before the terminal (station ).
The given conditions are: there are stations in total, people board at the starting station, and people alight at the last station (everyone gets off). The question is: how many people are on the train when it leaves station ?
Input Format
One line containing four integers , , , and , separated by single spaces. , , .
The data is guaranteed to have a unique solution. People may board and alight at the same station.
Output Format
One integer: the number of people on the train when it leaves station .
Sample Input
5 7 32 4
Sample Output
13
Hint
Assume the number of people boarding at station is .

Constraints
1s, 1024KiB for each test case.