2388: Next in line

Memory Limit:128 MB Time Limit:1.000 S
Creator:
Submit:5 Solved:5

Description

You know a family with three children. Their ages form an arithmetic sequence: the difference in ages between the middle child and youngest child is the same as the difference in ages between the oldest child and the middle child. For example, their ages could be 5, 10 and 15, since both adjacent pairs have a difference of 5 years. Given the ages of the youngest and middle children, what is the age of the oldest child? 
你认识一个有三个孩子的家庭。他们的年龄形成了一个等差数列:中间孩子和最小孩子之间的年龄差与最大孩子和中间孩子之间的年龄差相同。例如,他们的年龄可能是 5 岁、10 岁和 15 岁,因为相邻的两对都有 5 年的差距。
给定最小孩子和中间孩子的年龄,最大孩子的年龄是多少?

Input

The input consists of two integers, each on a separate line. 
The first line is the age Y of the youngest child (0 ≤ Y ≤ 50). 
The second line is the age M of the middle child (Y ≤ M ≤ 50). 
输入由两个整数组成,每个整数在单独的一行。
第一行是最小孩子的年龄 Y (0 ≤ Y ≤ 50)。
第二行是中间孩子的年龄 M (Y ≤ M ≤ 50)

Output

The output will be the age of the oldest child. 
输出将是最大孩子的年龄。

Sample Input

12
15

Sample Output

18

Source/Category