// Template for reading lines from stdin and printing the line count to stdout.
// Copy this code to your IDE to get started.

fun main() = println(generateSequence(::readlnOrNull).joinToString("").run {
    (1..length).first {
        (0 until it).none { x -> filterIndexed { i, _ -> i % it == x }.toSet().count { it != '?' } > 1 }
    }
})
