import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto s = readln.chomp; auto n = s.map!(c => cast(int)(c-'0')).array; auto h = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1]; auto o1 = 1 + h.indexed(n).sum; auto o2 = s.length.to!int; writeln(min(o1 + o2 + o1, o2 + o1 + o2)); }