//Normal #define _GLIBCXX_DEBUG #define ll long long #include using namespace std; using Graph = vector>; void print(auto a){ cout << a; } void prints(auto a){ cout << a << " "; } void prints(){ cout << " "; } void printl(auto a){ cout << a << endl; } void printl(){ cout << endl; } void fix(int n){ cout << fixed << setprecision(n); } int main(){ vector X(5); for(int i = 0; i < 5; i++) cin >> X[i]; int ans = 0; for(int i = 0; i < 5; i++){ string S = to_string(X[i]); int s = (int)S.size(); X[i]%15 == 0 ? ans += 8 : X[i]%3 == 0 or X[i]%5 == 0 ? ans += 4 : ans += s; } printl(ans); return 0; }