use std::io;
use std::io::Read;

// this code sucks

fn main() {
    let mut stdin = io::stdin();

    let mut buf: Vec<u8> = vec![];
    stdin.read_to_end(&mut buf).unwrap();

    let req: usize = 14; // change to 4 for part 1

    let mut r = 0;
    for i in req-1..buf.len() {
        let mut seen: [bool; 256] = [false; 256];
        let mut yes = true;
        for j in 0..req {
            if seen[buf[i - j] as usize] { yes = false; break; }
            seen[buf[i - j] as usize] = true;
        }
        if yes { r = i; break; }
    }

    println!("{}", r+1);
}