#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
class bint {
public:
string dig;
bint
};
int main() {
int num; int len = 0; long long unsigned int count = 1;
vector<int> table;
for (int i = 0; i <= 9; i++) {
cin >> num;
len += num;
table.push_back(num);
}
if (len == 1) {
if (*max_element(table.begin(), table.end()) == 1) cout << 1;
else if (*max_element(table.begin(), table.end()) == 2) cout << 2;
else if (*max_element(table.begin(), table.end()) == 6) cout << 3;
}
else if (len == 3) {
if (table[7] == 1) cout << 6;
else cout << 5;
}
else {
num = 2;
while ((trunc(log10(count)) + 1) < len) {
count = count * num;
num++;
}
cout << num-1;
}
return 0;
}