var fs = require('fs'); var length = fs.fstatSync(process.stdin.fd).size; var buffer = Buffer.alloc(length); var bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0); var input = buffer.toString('utf8', 0, bytesRead); var reg=/^1(3+)$/; var r=reg.exec(input); if (!r) console.log(-1); else console.log(r[1].length);