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

~/algor $ cat problems/boolean-sana-mavjudmi

Does the date exist?

Medium 1000 ms 64 MB 43%
Share

A date is given by three numbers: day $d$, month $m$ and year $y$. Check whether the statement is true: “such a date exists in the calendar”. Months $1$, $3$, $5$, $7$, $8$, $10$, $12$ have $31$ days, months $4$, $6$, $9$, $11$ have $30$ days. February (month $2$) has $29$ days in a leap year and $28$ days in other years. A year is a leap year if it is divisible by $4$ and not divisible by $100$, or divisible by $400$.

A calendar date: day, month and year

Input

One line with three positive integers: $d$, $m$ and $y$.

Output

One integer: $1$ if the statement is true, otherwise $0$.

Note

$1 \le d \le 31$
$1 \le m \le 12$
$1 \le y \le 9999$

Examples

Input #1
29 2 2024
Output #1
1
Input #2
31 4 2023
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.