Determining number of like-valued leading or trailing bits