I can not correctly count the length of strings