#!/usr/bin/python3 import sys line = sys.stdin.readline().rstrip() i = 0 while i < len(line) - 3: s = set(list(line[i:i+4])) if len(s) == 4: print(i + 4) break i += 1