class Solution(object):
def countSubstrings(self, s):
"""
:type s: str
:rtype: int
"""
res=[None]*len(s)
count=0
for i in range(len(s)):
res[i]=1
count+=1
for j in range(i):
if s[j]==s[i] and res[j+1]==1:
res[j]=1
count+=1
else:
res[j]=0
return count
# print Solution().countSubstrings("abc")