Fixed a bug when input contains 0 commands