import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;
public class C430 {
static int[] array;
static int digits = 0;
static long currentN = 2;
static boolean solved = false;
public static void main(String[] args) {
FastReader reader = new FastReader();
PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));
array = new int[10];
// 100000
// 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000
for (int i = 0; i < array.length; i++) {
int num = reader.nextInt();
digits += num;
array[i] = num;
}
// System.out.println("DIGITS = " + digits);
reader.close();
findLowest();
// while (!solved) {
// solve();
// }
writer.println(currentN);
writer.flush();
writer.close();
}
static void findLowest() {
long difference = digits - countDigits(currentN);
// System.out.println("---");
// System.out.println("CURRENT N = " + currentN);
// System.out.println("DIFFERENCE = " + difference);
if (difference == -1) {
currentN = 0;
return;
}
if (difference > 0) {
currentN += difference >= 1000 ? 100 : 1;
findLowest();
}
}
static long countDigits(long n) {
double total = 0;
for (long i = 2; i <= n; i++)
total += Math.log10(i);
return (int) (Math.floor(total)) + 1;
}
static void solve() {
for (int i = 0; i < array.length; i++) {
String factorial = factorial(currentN).toString();
final char c = (char) (i + '0');
long count = factorial.toString().chars().filter(ch -> ch == c).count();
if (count != array[i]) {
currentN += 1;
return;
}
}
solved = true;
}
static BigInteger factorial(long number) {
BigInteger factorial = BigInteger.ONE;
for (long i = number; i > 0; i--) {
factorial = factorial.multiply(BigInteger.valueOf(i));
}
return factorial;
}
static class FastReader {
private BufferedReader br;
private StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
void close() {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
st = null;
br = null;
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
int nextInt() {
return Integer.parseInt(next());
}
BigInteger nextBigInteger() {
return new BigInteger(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
long nextLong() {
return Long.parseLong(next());
}
}
}