#include <stdio.h>
#include <stdlib.h>
#define max(a, b) ((a) > (b) ? (a) : (b))
int najduziPalindrom(char s[],int l,int d)
{
	if(l>d)
	{
		return 0;
	}
	if(l==d)
	{
		return 1;
	}
	if(s[l]==s[d])
	{
		return 2+najduziPalindrom(s,l+1,d-1);
	}
	return max(najduziPalindrom(s, l, d-1),najduziPalindrom(s, l+1, d));
}
int najduzi_Palindrom(char s[])
{
	return najduziPalindrom(s, 0, sizeof(&s) - 1);
}
int main()
{
	char s[2*(10^5)];
	scanf("%s",s);
	printf("%d",najduzi_Palindrom(s));
	return 0;
}