#include "iostream" #include "climits" #include "list" #include "queue" #include "stack" #include "set" #include "functional" #include "algorithm" #include "math.h" #include "utility" #include "string" #include "map" #include "unordered_map" #include "iomanip" #include "random" using namespace std; const long long int MOD = 1000000007; int N, K; int num[10] = { 1,1,1,1,1,1,1,1,1,1 }; int box[10] = { 1,0,0,0,1,0,1,0,2,1 }; int a = 1; int b = 0; int main() { ios::sync_with_stdio(false); cin >> N; if (!N) { a += 1; b += 1; } while (N) { a += box[N % 10]; b += num[N % 10]; N /= 10; } cout << min(a * 2 + b, b * 2 + a) << endl; return 0; }