#!/usr/bin/env python3
s = input()
ret = len(s)
for i in range(0, len(s)-1):
  if int(s[i]) != i+1: ret = 0
print(ret)