
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	static int[][] memo;

	public static int hoge(int current, int n, String last) {
		return 0;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int ans = 0,k = 0,temp = 10;
		int[] a = new int[5],b = new int[5];
		String str;
		str = bf.readLine();
		a[0] = Integer.parseInt(str);
		str = bf.readLine();
		a[1] = Integer.parseInt(str);
		str = bf.readLine();
		a[2] = Integer.parseInt(str);
		str = bf.readLine();
		a[3] = Integer.parseInt(str);
		str = bf.readLine();
		a[4] = Integer.parseInt(str);
		for(int i = 0;i < 5;++i) {
			b[i] = a[i]%10;
			if(b[i] < temp && b[i] != 0) {
				temp = b[i];
				k = i;
			}
			a[i] /= 10;
		}
		for(int i = 0;i < 5;++i) {
			if(k == i) {
				continue;
			}
			if(b[i] == 0) {
				ans += a[i]*10;
			} else {
				ans += (a[i]+1)*10;
			}
		}
		ans += a[k]*10 + b[k];
		System.out.println(ans);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	static int[][] memo;

	public static int hoge(int current, int n, String last) {
		return 0;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int ans = 0,k = 0,temp = 10;
		int[] a = new int[5],b = new int[5];
		String str;
		str = bf.readLine();
		a[0] = Integer.parseInt(str);
		str = bf.readLine();
		a[1] = Integer.parseInt(str);
		str = bf.readLine();
		a[2] = Integer.parseInt(str);
		str = bf.readLine();
		a[3] = Integer.parseInt(str);
		str = bf.readLine();
		a[4] = Integer.parseInt(str);
		for(int i = 0;i < 5;++i) {
			b[i] = a[i]%10;
			if(b[i] < temp && b[i] != 0) {
				temp = b[i];
				k = i;
			}
			a[i] /= 10;
		}
		for(int i = 0;i < 5;++i) {
			if(k == i) {
				continue;
			}
			if(b[i] == 0) {
				ans += a[i]*10;
			} else {
				ans += (a[i]+1)*10;
			}
		}
		ans += a[k]*10 + b[k];
		System.out.println(ans);
	}
} Main static int[][] memo; memo public static int hoge(int current, int n, String last) {
		return 0;
	} hoge {
		return 0;
	} return 0; 0 int current current int n n String last last public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int ans = 0,k = 0,temp = 10;
		int[] a = new int[5],b = new int[5];
		String str;
		str = bf.readLine();
		a[0] = Integer.parseInt(str);
		str = bf.readLine();
		a[1] = Integer.parseInt(str);
		str = bf.readLine();
		a[2] = Integer.parseInt(str);
		str = bf.readLine();
		a[3] = Integer.parseInt(str);
		str = bf.readLine();
		a[4] = Integer.parseInt(str);
		for(int i = 0;i < 5;++i) {
			b[i] = a[i]%10;
			if(b[i] < temp && b[i] != 0) {
				temp = b[i];
				k = i;
			}
			a[i] /= 10;
		}
		for(int i = 0;i < 5;++i) {
			if(k == i) {
				continue;
			}
			if(b[i] == 0) {
				ans += a[i]*10;
			} else {
				ans += (a[i]+1)*10;
			}
		}
		ans += a[k]*10 + b[k];
		System.out.println(ans);
	} main {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int ans = 0,k = 0,temp = 10;
		int[] a = new int[5],b = new int[5];
		String str;
		str = bf.readLine();
		a[0] = Integer.parseInt(str);
		str = bf.readLine();
		a[1] = Integer.parseInt(str);
		str = bf.readLine();
		a[2] = Integer.parseInt(str);
		str = bf.readLine();
		a[3] = Integer.parseInt(str);
		str = bf.readLine();
		a[4] = Integer.parseInt(str);
		for(int i = 0;i < 5;++i) {
			b[i] = a[i]%10;
			if(b[i] < temp && b[i] != 0) {
				temp = b[i];
				k = i;
			}
			a[i] /= 10;
		}
		for(int i = 0;i < 5;++i) {
			if(k == i) {
				continue;
			}
			if(b[i] == 0) {
				ans += a[i]*10;
			} else {
				ans += (a[i]+1)*10;
			}
		}
		ans += a[k]*10 + b[k];
		System.out.println(ans);
	} BufferedReader bf = null; bf null bf = new BufferedReader(new InputStreamReader(System.in)) bf new BufferedReader(new InputStreamReader(System.in)) int ans = 0 ans 0 k = 0 k 0 temp = 10; temp 10 int[] a = new int[5] a new int[5] 5 b = new int[5]; b new int[5] 5 String str; str str = bf.readLine() str bf.readLine() bf.readLine bf a[0] = Integer.parseInt(str) a[0] a 0 Integer.parseInt(str) Integer.parseInt Integer str str = bf.readLine() str bf.readLine() bf.readLine bf a[1] = Integer.parseInt(str) a[1] a 1 Integer.parseInt(str) Integer.parseInt Integer str str = bf.readLine() str bf.readLine() bf.readLine bf a[2] = Integer.parseInt(str) a[2] a 2 Integer.parseInt(str) Integer.parseInt Integer str str = bf.readLine() str bf.readLine() bf.readLine bf a[3] = Integer.parseInt(str) a[3] a 3 Integer.parseInt(str) Integer.parseInt Integer str str = bf.readLine() str bf.readLine() bf.readLine bf a[4] = Integer.parseInt(str) a[4] a 4 Integer.parseInt(str) Integer.parseInt Integer str for(int i = 0;i < 5;++i) {
			b[i] = a[i]%10;
			if(b[i] < temp && b[i] != 0) {
				temp = b[i];
				k = i;
			}
			a[i] /= 10;
		} int i = 0; int i = 0; i 0 i < 5 i 5 ++i ++i i {
			b[i] = a[i]%10;
			if(b[i] < temp && b[i] != 0) {
				temp = b[i];
				k = i;
			}
			a[i] /= 10;
		} {
			b[i] = a[i]%10;
			if(b[i] < temp && b[i] != 0) {
				temp = b[i];
				k = i;
			}
			a[i] /= 10;
		} b[i] = a[i]%10 b[i] b i a[i]%10 a[i] a i 10 if(b[i] < temp && b[i] != 0) {
				temp = b[i];
				k = i;
			} b[i] < temp && b[i] != 0 b[i] < temp b[i] b i temp b[i] != 0 b[i] b i 0 {
				temp = b[i];
				k = i;
			} temp = b[i] temp b[i] b i k = i k i a[i] /= 10 a[i] a i 10 for(int i = 0;i < 5;++i) {
			if(k == i) {
				continue;
			}
			if(b[i] == 0) {
				ans += a[i]*10;
			} else {
				ans += (a[i]+1)*10;
			}
		} int i = 0; int i = 0; i 0 i < 5 i 5 ++i ++i i {
			if(k == i) {
				continue;
			}
			if(b[i] == 0) {
				ans += a[i]*10;
			} else {
				ans += (a[i]+1)*10;
			}
		} {
			if(k == i) {
				continue;
			}
			if(b[i] == 0) {
				ans += a[i]*10;
			} else {
				ans += (a[i]+1)*10;
			}
		} if(k == i) {
				continue;
			} k == i k i {
				continue;
			} continue; if(b[i] == 0) {
				ans += a[i]*10;
			} else {
				ans += (a[i]+1)*10;
			} b[i] == 0 b[i] b i 0 {
				ans += a[i]*10;
			} ans += a[i]*10 ans a[i]*10 a[i] a i 10 {
				ans += (a[i]+1)*10;
			} ans += (a[i]+1)*10 ans (a[i]+1)*10 (a[i]+1) a[i] a i 1 10 ans += a[k]*10 + b[k] ans a[k]*10 + b[k] a[k]*10 a[k] a k 10 b[k] b k System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	static int[][] memo;

	public static int hoge(int current, int n, String last) {
		return 0;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int ans = 0,k = 0,temp = 10;
		int[] a = new int[5],b = new int[5];
		String str;
		str = bf.readLine();
		a[0] = Integer.parseInt(str);
		str = bf.readLine();
		a[1] = Integer.parseInt(str);
		str = bf.readLine();
		a[2] = Integer.parseInt(str);
		str = bf.readLine();
		a[3] = Integer.parseInt(str);
		str = bf.readLine();
		a[4] = Integer.parseInt(str);
		for(int i = 0;i < 5;++i) {
			b[i] = a[i]%10;
			if(b[i] < temp && b[i] != 0) {
				temp = b[i];
				k = i;
			}
			a[i] /= 10;
		}
		for(int i = 0;i < 5;++i) {
			if(k == i) {
				continue;
			}
			if(b[i] == 0) {
				ans += a[i]*10;
			} else {
				ans += (a[i]+1)*10;
			}
		}
		ans += a[k]*10 + b[k];
		System.out.println(ans);
	}
} public class Main {

	static int[][] memo;

	public static int hoge(int current, int n, String last) {
		return 0;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int ans = 0,k = 0,temp = 10;
		int[] a = new int[5],b = new int[5];
		String str;
		str = bf.readLine();
		a[0] = Integer.parseInt(str);
		str = bf.readLine();
		a[1] = Integer.parseInt(str);
		str = bf.readLine();
		a[2] = Integer.parseInt(str);
		str = bf.readLine();
		a[3] = Integer.parseInt(str);
		str = bf.readLine();
		a[4] = Integer.parseInt(str);
		for(int i = 0;i < 5;++i) {
			b[i] = a[i]%10;
			if(b[i] < temp && b[i] != 0) {
				temp = b[i];
				k = i;
			}
			a[i] /= 10;
		}
		for(int i = 0;i < 5;++i) {
			if(k == i) {
				continue;
			}
			if(b[i] == 0) {
				ans += a[i]*10;
			} else {
				ans += (a[i]+1)*10;
			}
		}
		ans += a[k]*10 + b[k];
		System.out.println(ans);
	}
} Main

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	static int[][] memo;

	public static int hoge(int current, int n, String last) {
		return 0;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int ans = 0,k = 0,temp = 10;
		int[] a = new int[5],b = new int[5];
		String str;
		str = bf.readLine();
		a[0] = Integer.parseInt(str);
		str = bf.readLine();
		a[1] = Integer.parseInt(str);
		str = bf.readLine();
		a[2] = Integer.parseInt(str);
		str = bf.readLine();
		a[3] = Integer.parseInt(str);
		str = bf.readLine();
		a[4] = Integer.parseInt(str);
		for(int i = 0;i < 5;++i) {
			b[i] = a[i]%10;
			if(b[i] < temp && b[i] != 0) {
				temp = b[i];
				k = i;
			}
			a[i] /= 10;
		}
		for(int i = 0;i < 5;++i) {
			if(k == i) {
				continue;
			}
			if(b[i] == 0) {
				ans += a[i]*10;
			} else {
				ans += (a[i]+1)*10;
			}
		}
		ans += a[k]*10 + b[k];
		System.out.println(ans);
	}
}