```
class Solution(object):
def countSubstrings(self, s):
"""
:type s: str
:rtype: int
"""
length = count = len(s)
if not length:
return count
for i in range(length-1):
# even length
start, end = i, i+1
while start > -1 and end < length and s[start] == s[end]:
start -= 1
end += 1
count += 1
# odd length
start, end = i, i+2
while start > -1 and end < length and s[start] == s[end]:
start -= 1
end += 1
count += 1
return count
```