CCCGuide

Problem J1: Next in line

2013 · J1 · Original problem · DMOJ

Problem 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?

Input Specification

The input consists of two integers, each on a separate line. The first line is the age YY of the youngest child (0≤Y≤500 \leq Y \leq 50). The second line is the age MM of the middle child (Y≤M≤50Y \leq M \leq 50).

Output Specification

The output will be the age of the oldest child.

Sample Input 1

12
15

Output for Sample Input 1

18

Sample Input 2

10
10

Output for Sample Input 4

10