inpt = input()

m = 0
isFirst = True
def recursion(txt, counter):
    if len(txt) == 0:
        return 0

    while txt[0] == "0":
        if txt == "0":
            return 0
        txt = txt[1:]

    flag = isPrime(int(txt))

    global m

    if not flag:
        if not (txt == inpt):
            return counter
    else:
        counter += 1

    m = max(m, counter)

    for i in range(0, len(txt)):
        (recursion(txt[:i] + txt[i+1:], counter))


def isPrime(a: int):
    if a <= 1:
        return False

    if a == 2:
        return True

    for i in range(2, int(a ** 0.5)):
        if a % i == 0:
            return False

    return True

recursion(inpt, 0)

print(m)

