Codeforces Problem 370A

How do we solve this problem using BFS?
https://codeforces.com/contest/370/problem/A