Codeforces problem Div 1 B

link- https://codeforces.com/problemset/problem/547/B