#include <iostream>
#include <string>

using namespace std;

int main()
{
    string rec;

    cin >> rec;

	int poz2, poz1;

	for (int i = 0; i < int(rec.length()/2); i++)
	{
		if (rec[i+1] != rec[rec.length() - i])
		{
			poz1 = i + 1;
			break;
		}
	}

	for (int i = int(rec.length()/2); i > 0; i--)
	{
		if (rec[i] != rec[rec.length() - i + 1])
		{
			poz2 = i;
			break;
		}
	}

	cout << abs(poz1 - poz2);
}