with open("input") as f: print( (recursion := lambda line, i, size: i+size if all([line[i:i+size].count(c)==1 for c in line[i:i+size]]) else recursion(line, i+1, size))(f.readline(), 0, 4) )
with open("input") as f: print( (lambda line, size: min([i+size if all([line[i:i+size].count(c)==1 for c in line[i:i+size]]) else len(line) for i in range(len(line))]))(f.readline(), 4) )