```
class Solution:
# @param {string} s
# @return {integer}
def lengthOfLastWord(self, s):
n = len(s)
#print n
if n == 1:
if s[0] == ' ':
return 0
else:
return 1
count = 0
if n==0:
return 0
for i in range(n-1,-1,-1):
print 'kk: ',i,s[i]
if s[i] != ' ':
count += 1
elif s[i] == ' ' and count > 0:
return count
return count
```