Problema adaptado de \href{https://codeforces.com/problemset/problem/104/C}{Codeforces Beta Round 80 (Div. 2 Only, Problem C)}.