696 accepted (getting the solution idea from forums)