commit hanxin counting algorithm