#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 2 * 1000 + 47;


int main()
{
    // freopen("in.txt", "r", stdin);
    string s;
    cin >> s;

    int ans = INF;
    FOR(ch, 'a', 'z'+1)
    {
        string S = s;
        int cnt = 0;
        while(true)
        {
            int ok = 1;
            FOR(i, 0, SZ(S))
            if (S[i] != ch)ok = 0;
            if (ok)break;
            ++cnt;
            string SS = "";
            FOR(i, 0, SZ(S) - 1)
            {
                if (S[i] == ch || S[i+1] == ch)
                    SS += ch;
                else SS += S[i];
            }
            S = SS;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    
    
    return 0;
}




