#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int najkracipalindrom(const string& T,int a,int b) 
{
if(a==b)
	return 1;
if(a>b)
	return 0;
if (T[a]==T[b])
	return 2 + najkracipalindrom(T,a+1,b-1);
	return max(najkracipalindrom(T,a,b-1),
	najkracipalindrom(T,a+1,b));
	
}
int najkracipalindrom(const string& T) 
{
	return najkracipalindrom(T,0,T.length()-1);
}

int main()
{
string T;
cin >> T;
cout << najkracipalindrom(T) << endl;
return 0;
}