#include <iostream>
using namespace std;
int izbroj(int n)
{
	int br = 0;
	while (n != 0)
	{
		n = n / 10;
		++br;
	}
	return br;
}
int main()
{
	int n;
	cin >> n;
	int i = 0;
	int cifre=0;
	int digits;
	int arr[100000] = { 0 };
	digits = izbroj(n);
	while (n >=1)
	{

		arr[digits-i-1] = n % 10;
		n = n / 10;
		i++;
		
	}
	i--;
	if (arr[0] == arr[i])
	{
		
		int brojac=0;
		
			for (int o = 0; o < i - 1; o++)
			{
				if (arr[1] == arr[1 + o])
				{
					brojac++;
					
				}
			}
			
		
		if (brojac == i - 1)
		{
			cout << "1";
			return 0;
		}
	}
	for (int j = i/2; j <= i; j++)
	{
		
		if (j == i)
		{
			for (int k = j; k >= 0; k--)
			{
				
				if (arr[k] == arr[j])
				{
					for (int y = k; y < j; y++)
					{
						if (arr[y] != arr[j])
						{
							arr[y] = arr[j];
							cifre++;
						}
					}
				}
			}
			for (j = i / 2; j >= 0; j--)
			{
				for (int k = j; k >= 0; k--)
				{
					if (arr[j] == arr[k])
					{
						for (int y = k; y > j; y--)
						{
							if (arr[y] != arr[j])
							{
								arr[y] = arr[j];
								cifre++;


							}

						}

					}

					if (k == i)
					{

						for (k = j; k >= 0; k--)
						{

							if (arr[j] == arr[k])
							{

								for (int y = k + 1; y < j; y++)
								{
									if (arr[y] != arr[j])
									{
										arr[y] = arr[j];
										cifre++;

									}

								}
							}
						}
						
						k = i + 2;
					}

				}
			}
			j = i + 1;
			
		}
		else
		{
			for (int k = j; k <= i; k++)
			{
				if (arr[j] == arr[k])
				{
					for (int y = k; y > j; y--)
					{
						if (arr[y] != arr[j])
						{
							arr[y] = arr[j];
							
							cifre+=1;
							
							
						}

					}
				}
				if (k == i)
				{
					for (k = j; k >= 0; k--)
					{
						
						if (arr[j] == arr[k])
						{
							
							for (int y = k+1; y <j; y++)
							{
								
								if (arr[y] != arr[j])
								{
									arr[y] = arr[j];
									cifre++;
									
								}

							}
						}
					}
					k = i+1;
				}
				
			}
		}
	}
	
	cout << cifre;
	return 0;
}