import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return readln.split.to!(T[]); } alias readint = read!int; alias readints = reads!int; int calc(string s) { if (s.front != '1') return -1; if (s.length == 1) return -1; if (s[1..$].any!(e => e != '3')) return -1; return cast(int)s.length - 1; } void main() { string s = read!string; writeln(calc(s)); }