import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.functional;

void main() {
    char[] s = readln.chomp.to!(char[]);
    int n = s.length.to!int;

    bool[] app = new bool[](26);

    foreach (ch ; s) {
        app[ch - 'a'] = 1;
    }

    debug {
        writeln("app:", app);
    }

    if (app.sum == 1) {
        writeln(0);
        return;
    }

    int ans = 200;

    foreach (alp ; 0 .. 26) {
        if (!app[alp]) continue;

        auto sc = s.dup;
        int cnt;

        debug {
            writeln((alp + 'a').to!char);
        }

        foreach (i ; 0 .. n - 1) {
            foreach (j ; 0 .. n - 1 - i) {
                if (sc[j + 1] == (alp + 'a')) {
                    sc[j] = sc[j + 1];
                }
            }

            debug {
                writeln("sc:", sc);
            }

            bool flag = true;

            foreach (j ; 0 .. n - 1 - i - 1) {
                if (sc[j] != sc[j + 1]) {
                    flag = false;
                }
            }

            cnt++;

            if (flag) {
                break;
            }
        }

        ans = min(ans, cnt);
    }

    writeln(ans);
}

void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg ; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}