Imports System
Imports System.IO
Imports System.Text
Imports System.Numerics
Imports System.Collections
Imports System.Collections.Generic
Imports System.Diagnostics

class Program
    shared function python_call (ByVal python as String) as String
        dim pinfo as new ProcessStartInfo()
        pinfo.FileName = "python"
        pinfo.Arguments = "-c '" + python + "'"
        pinfo.CreateNoWindow = true
        pinfo.UseShellExecute = false
        pinfo.RedirectStandardOutput = true
        dim p as Process = Process.Start(pinfo)
        p.WaitForExit()
        return p.StandardOutput.ReadToEnd()
    end function
    
    shared sub main ()
        Console.WriteLine(python_call("def main():\n    S = input()\n    cnt = 0\n    l = list(S)\n    while 1:\n        for i in set(''.join(l)):\n            if all((1 if i in x else 0) for x in l):\n                print(cnt)\n                return\n        cnt += 1\n        l = [l[x]+S[x+cnt] for x in range(len(l)-1)]\n    \nif __name__ == '__main__':\n    main()"))
    end sub
end class