a=gets;puts a.match?(/^13+$/)?a.size-1:-1