#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <stack>
#include <utility>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
int main()
{
	char n[100050];
	gets(n);
	int res = 9999999;
	int p=0,k=0,j;
	for(int i = 0; i < strlen(n)-1; ++i)
	{
		if(n[i] != n[i+1])
		{
			p = i;
			for(j = i+1; n[i] != n[j] && j < strlen(n);j++){}
			k = j-1;
			//cout << "\nk = " << k  << ",p = " << p << endl;
		}
		if(res > k-p && k-p != 0)res = k-p;
	}
	cout << res;
}