count the occurence of 1 from number 1~N