```
class Solution(object):
def longestPalindrome(self, s):
"""
:type s: str
:rtype: int
"""
dict1={}
for each in s:
if each in dict1:
dict1[each]+=1
else:
dict1[each]=1
listvalue=list(dict1.values())
listvalue1=[x-int(x/2)*2 for x in listvalue]
if max(listvalue1)==0:
return sum(listvalue)
else:
return sum(listvalue)-sum(listvalue1)+1
```