Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/funksiya-yoshni-hisoblash

Calculating age

Medium 1000 ms 128 MB 45%
Share

Write a function Age(d1, m1, y1, d2, m2, y2) that returns the age of a person born on $d_{1}.m_{1}.y_{1}$ on the date $d_{2}.m_{2}.y_{2}$ — the number of full years that have passed. For a person born on February $29$, the birthday in a non-leap year is March $1$.

Example 1: Age(15, 3, 2000, 20, 6, 2024) → 24

Example 2: Age(20, 9, 1995, 19, 9, 2024) → 28 — the birthday in $2024$ (September $20$) has not come yet.

Write only the function body.

The date of birth and today's date go into the function Age, which returns the number of full years passed

Input

One line with six positive integers: $d_{1}$, $m_{1}$, $y_{1}$ (the date of birth: day, month, year) and $d_{2}$, $m_{2}$, $y_{2}$ (today's date) — the arguments of the function.

Output

The value returned by the function: an integer.

Note

$1 \le d_{1}, d_{2} \le 31$
$1 \le m_{1}, m_{2} \le 12$
$1900 \le y_{1}, y_{2} \le 2100$
The dates are valid; the date $d_{2}.m_{2}.y_{2}$ is not earlier than $d_{1}.m_{1}.y_{1}$.

Examples

Input #1
15 3 2000 20 6 2024
Output #1
24
Input #2
20 9 1995 19 9 2024
Output #2
28

Sign in to submit a solution

Signing up is free and takes a minute.