codeforces; solve "Digital Counter" from Round #282 (Div. 2)