import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		int D = Integer.parseInt(sc.next());
		int E = Integer.parseInt(sc.next());
		sc.close();

		int time = Integer.MAX_VALUE;
		int[] list = {A, B, C, D, E};

		for(int i = 0; i < factorial(5); i++) {
			int tmp = 0;
			for(int j = 0; j < list.length; j++) {
				tmp += list[j];
				if(j == list.length - 1) {
					
				}else {
					if(tmp % 10 == 0) {
						continue;
					}else {
						tmp += 10 - tmp % 10;
					}
				}
			}
			time = Math.min(time, tmp);
			next_permutation(list, 0, list.length);
		}
		System.out.println(time);
	}

	//階乗
	static int factorial(int num) {
		if(num == 0) return 1;

		return num * factorial(num - 1);
	}

	//順列を網羅するメソッド
	static boolean next_permutation(int[] array, int start, int end) {
		if(array == null || start > end || start < 0 || end > array.length) {
			return false;
		}
		for(int i=end-2; i>=start; i--) {
			if(array[i] < array[i+1]) {
				int j = end - 1;
				while(array[i] >= array[j]) {
					j--;
				}

				//swap
				int tmp = array[j];
				array[j] = array[i];
				array[i] = tmp;

				Arrays.sort(array, i+1, end);

				return true;
			}
		}

		return false;
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		int D = Integer.parseInt(sc.next());
		int E = Integer.parseInt(sc.next());
		sc.close();

		int time = Integer.MAX_VALUE;
		int[] list = {A, B, C, D, E};

		for(int i = 0; i < factorial(5); i++) {
			int tmp = 0;
			for(int j = 0; j < list.length; j++) {
				tmp += list[j];
				if(j == list.length - 1) {
					
				}else {
					if(tmp % 10 == 0) {
						continue;
					}else {
						tmp += 10 - tmp % 10;
					}
				}
			}
			time = Math.min(time, tmp);
			next_permutation(list, 0, list.length);
		}
		System.out.println(time);
	}

	//階乗
	static int factorial(int num) {
		if(num == 0) return 1;

		return num * factorial(num - 1);
	}

	//順列を網羅するメソッド
	static boolean next_permutation(int[] array, int start, int end) {
		if(array == null || start > end || start < 0 || end > array.length) {
			return false;
		}
		for(int i=end-2; i>=start; i--) {
			if(array[i] < array[i+1]) {
				int j = end - 1;
				while(array[i] >= array[j]) {
					j--;
				}

				//swap
				int tmp = array[j];
				array[j] = array[i];
				array[i] = tmp;

				Arrays.sort(array, i+1, end);

				return true;
			}
		}

		return false;
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		int D = Integer.parseInt(sc.next());
		int E = Integer.parseInt(sc.next());
		sc.close();

		int time = Integer.MAX_VALUE;
		int[] list = {A, B, C, D, E};

		for(int i = 0; i < factorial(5); i++) {
			int tmp = 0;
			for(int j = 0; j < list.length; j++) {
				tmp += list[j];
				if(j == list.length - 1) {
					
				}else {
					if(tmp % 10 == 0) {
						continue;
					}else {
						tmp += 10 - tmp % 10;
					}
				}
			}
			time = Math.min(time, tmp);
			next_permutation(list, 0, list.length);
		}
		System.out.println(time);
	} main {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		int D = Integer.parseInt(sc.next());
		int E = Integer.parseInt(sc.next());
		sc.close();

		int time = Integer.MAX_VALUE;
		int[] list = {A, B, C, D, E};

		for(int i = 0; i < factorial(5); i++) {
			int tmp = 0;
			for(int j = 0; j < list.length; j++) {
				tmp += list[j];
				if(j == list.length - 1) {
					
				}else {
					if(tmp % 10 == 0) {
						continue;
					}else {
						tmp += 10 - tmp % 10;
					}
				}
			}
			time = Math.min(time, tmp);
			next_permutation(list, 0, list.length);
		}
		System.out.println(time);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = Integer.parseInt(sc.next()); A Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int B = Integer.parseInt(sc.next()); B Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int C = Integer.parseInt(sc.next()); C Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int D = Integer.parseInt(sc.next()); D Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int E = Integer.parseInt(sc.next()); E Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc sc.close() sc.close sc int time = Integer.MAX_VALUE; time Integer.MAX_VALUE Integer Integer.MAX_VALUE int[] list = {A, B, C, D, E}; list {A, B, C, D, E} A B C D E for(int i = 0; i < factorial(5); i++) {
			int tmp = 0;
			for(int j = 0; j < list.length; j++) {
				tmp += list[j];
				if(j == list.length - 1) {
					
				}else {
					if(tmp % 10 == 0) {
						continue;
					}else {
						tmp += 10 - tmp % 10;
					}
				}
			}
			time = Math.min(time, tmp);
			next_permutation(list, 0, list.length);
		} int i = 0; int i = 0; i 0 i < factorial(5) i factorial(5) factorial 5 i++ i++ i {
			int tmp = 0;
			for(int j = 0; j < list.length; j++) {
				tmp += list[j];
				if(j == list.length - 1) {
					
				}else {
					if(tmp % 10 == 0) {
						continue;
					}else {
						tmp += 10 - tmp % 10;
					}
				}
			}
			time = Math.min(time, tmp);
			next_permutation(list, 0, list.length);
		} {
			int tmp = 0;
			for(int j = 0; j < list.length; j++) {
				tmp += list[j];
				if(j == list.length - 1) {
					
				}else {
					if(tmp % 10 == 0) {
						continue;
					}else {
						tmp += 10 - tmp % 10;
					}
				}
			}
			time = Math.min(time, tmp);
			next_permutation(list, 0, list.length);
		} int tmp = 0; tmp 0 for(int j = 0; j < list.length; j++) {
				tmp += list[j];
				if(j == list.length - 1) {
					
				}else {
					if(tmp % 10 == 0) {
						continue;
					}else {
						tmp += 10 - tmp % 10;
					}
				}
			} int j = 0; int j = 0; j 0 j < list.length j list.length list list.length j++ j++ j {
				tmp += list[j];
				if(j == list.length - 1) {
					
				}else {
					if(tmp % 10 == 0) {
						continue;
					}else {
						tmp += 10 - tmp % 10;
					}
				}
			} {
				tmp += list[j];
				if(j == list.length - 1) {
					
				}else {
					if(tmp % 10 == 0) {
						continue;
					}else {
						tmp += 10 - tmp % 10;
					}
				}
			} tmp += list[j] tmp list[j] list j if(j == list.length - 1) {
					
				}else {
					if(tmp % 10 == 0) {
						continue;
					}else {
						tmp += 10 - tmp % 10;
					}
				} j == list.length - 1 j list.length - 1 list.length list list.length 1 {
					
				} {
					if(tmp % 10 == 0) {
						continue;
					}else {
						tmp += 10 - tmp % 10;
					}
				} if(tmp % 10 == 0) {
						continue;
					}else {
						tmp += 10 - tmp % 10;
					} tmp % 10 == 0 tmp % 10 tmp 10 0 {
						continue;
					} continue; {
						tmp += 10 - tmp % 10;
					} tmp += 10 - tmp % 10 tmp 10 - tmp % 10 10 tmp % 10 tmp 10 time = Math.min(time, tmp) time Math.min(time, tmp) Math.min Math time tmp next_permutation(list, 0, list.length) next_permutation list 0 list.length list list.length System.out.println(time) System.out.println System.out System System.out time String[] args args //階乗
	static int factorial(int num) {
		if(num == 0) return 1;

		return num * factorial(num - 1);
	} factorial {
		if(num == 0) return 1;

		return num * factorial(num - 1);
	} if(num == 0) return 1; num == 0 num 0 return 1; 1 return num * factorial(num - 1); num * factorial(num - 1) num factorial(num - 1) factorial num - 1 num 1 int num num //順列を網羅するメソッド
	static boolean next_permutation(int[] array, int start, int end) {
		if(array == null || start > end || start < 0 || end > array.length) {
			return false;
		}
		for(int i=end-2; i>=start; i--) {
			if(array[i] < array[i+1]) {
				int j = end - 1;
				while(array[i] >= array[j]) {
					j--;
				}

				//swap
				int tmp = array[j];
				array[j] = array[i];
				array[i] = tmp;

				Arrays.sort(array, i+1, end);

				return true;
			}
		}

		return false;
	} next_permutation {
		if(array == null || start > end || start < 0 || end > array.length) {
			return false;
		}
		for(int i=end-2; i>=start; i--) {
			if(array[i] < array[i+1]) {
				int j = end - 1;
				while(array[i] >= array[j]) {
					j--;
				}

				//swap
				int tmp = array[j];
				array[j] = array[i];
				array[i] = tmp;

				Arrays.sort(array, i+1, end);

				return true;
			}
		}

		return false;
	} if(array == null || start > end || start < 0 || end > array.length) {
			return false;
		} array == null || start > end || start < 0 || end > array.length start < 0 array == null || start > end || start < 0 || end > array.length array == null array null start > end start end start < 0 start 0 end > array.length end array.length array array.length {
			return false;
		} return false; false for(int i=end-2; i>=start; i--) {
			if(array[i] < array[i+1]) {
				int j = end - 1;
				while(array[i] >= array[j]) {
					j--;
				}

				//swap
				int tmp = array[j];
				array[j] = array[i];
				array[i] = tmp;

				Arrays.sort(array, i+1, end);

				return true;
			}
		} int i=end-2; int i=end-2; i end-2 end 2 i>=start i start i-- i-- i {
			if(array[i] < array[i+1]) {
				int j = end - 1;
				while(array[i] >= array[j]) {
					j--;
				}

				//swap
				int tmp = array[j];
				array[j] = array[i];
				array[i] = tmp;

				Arrays.sort(array, i+1, end);

				return true;
			}
		} {
			if(array[i] < array[i+1]) {
				int j = end - 1;
				while(array[i] >= array[j]) {
					j--;
				}

				//swap
				int tmp = array[j];
				array[j] = array[i];
				array[i] = tmp;

				Arrays.sort(array, i+1, end);

				return true;
			}
		} if(array[i] < array[i+1]) {
				int j = end - 1;
				while(array[i] >= array[j]) {
					j--;
				}

				//swap
				int tmp = array[j];
				array[j] = array[i];
				array[i] = tmp;

				Arrays.sort(array, i+1, end);

				return true;
			} array[i] < array[i+1] array[i] array i array[i+1] array i+1 i 1 {
				int j = end - 1;
				while(array[i] >= array[j]) {
					j--;
				}

				//swap
				int tmp = array[j];
				array[j] = array[i];
				array[i] = tmp;

				Arrays.sort(array, i+1, end);

				return true;
			} int j = end - 1; j end - 1 end 1 while(array[i] >= array[j]) {
					j--;
				} array[i] >= array[j] array[i] array i array[j] array j {
					j--;
				} j-- j int tmp = array[j]; tmp array[j] array j array[j] = array[i] array[j] array j array[i] array i array[i] = tmp array[i] array i tmp Arrays.sort(array, i+1, end) Arrays.sort Arrays array i+1 i 1 end return true; true return false; false int[] array array int start start int end end public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		int D = Integer.parseInt(sc.next());
		int E = Integer.parseInt(sc.next());
		sc.close();

		int time = Integer.MAX_VALUE;
		int[] list = {A, B, C, D, E};

		for(int i = 0; i < factorial(5); i++) {
			int tmp = 0;
			for(int j = 0; j < list.length; j++) {
				tmp += list[j];
				if(j == list.length - 1) {
					
				}else {
					if(tmp % 10 == 0) {
						continue;
					}else {
						tmp += 10 - tmp % 10;
					}
				}
			}
			time = Math.min(time, tmp);
			next_permutation(list, 0, list.length);
		}
		System.out.println(time);
	}

	//階乗
	static int factorial(int num) {
		if(num == 0) return 1;

		return num * factorial(num - 1);
	}

	//順列を網羅するメソッド
	static boolean next_permutation(int[] array, int start, int end) {
		if(array == null || start > end || start < 0 || end > array.length) {
			return false;
		}
		for(int i=end-2; i>=start; i--) {
			if(array[i] < array[i+1]) {
				int j = end - 1;
				while(array[i] >= array[j]) {
					j--;
				}

				//swap
				int tmp = array[j];
				array[j] = array[i];
				array[i] = tmp;

				Arrays.sort(array, i+1, end);

				return true;
			}
		}

		return false;
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		int D = Integer.parseInt(sc.next());
		int E = Integer.parseInt(sc.next());
		sc.close();

		int time = Integer.MAX_VALUE;
		int[] list = {A, B, C, D, E};

		for(int i = 0; i < factorial(5); i++) {
			int tmp = 0;
			for(int j = 0; j < list.length; j++) {
				tmp += list[j];
				if(j == list.length - 1) {
					
				}else {
					if(tmp % 10 == 0) {
						continue;
					}else {
						tmp += 10 - tmp % 10;
					}
				}
			}
			time = Math.min(time, tmp);
			next_permutation(list, 0, list.length);
		}
		System.out.println(time);
	}

	//階乗
	static int factorial(int num) {
		if(num == 0) return 1;

		return num * factorial(num - 1);
	}

	//順列を網羅するメソッド
	static boolean next_permutation(int[] array, int start, int end) {
		if(array == null || start > end || start < 0 || end > array.length) {
			return false;
		}
		for(int i=end-2; i>=start; i--) {
			if(array[i] < array[i+1]) {
				int j = end - 1;
				while(array[i] >= array[j]) {
					j--;
				}

				//swap
				int tmp = array[j];
				array[j] = array[i];
				array[i] = tmp;

				Arrays.sort(array, i+1, end);

				return true;
			}
		}

		return false;
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		int D = Integer.parseInt(sc.next());
		int E = Integer.parseInt(sc.next());
		sc.close();

		int time = Integer.MAX_VALUE;
		int[] list = {A, B, C, D, E};

		for(int i = 0; i < factorial(5); i++) {
			int tmp = 0;
			for(int j = 0; j < list.length; j++) {
				tmp += list[j];
				if(j == list.length - 1) {
					
				}else {
					if(tmp % 10 == 0) {
						continue;
					}else {
						tmp += 10 - tmp % 10;
					}
				}
			}
			time = Math.min(time, tmp);
			next_permutation(list, 0, list.length);
		}
		System.out.println(time);
	}

	//階乗
	static int factorial(int num) {
		if(num == 0) return 1;

		return num * factorial(num - 1);
	}

	//順列を網羅するメソッド
	static boolean next_permutation(int[] array, int start, int end) {
		if(array == null || start > end || start < 0 || end > array.length) {
			return false;
		}
		for(int i=end-2; i>=start; i--) {
			if(array[i] < array[i+1]) {
				int j = end - 1;
				while(array[i] >= array[j]) {
					j--;
				}

				//swap
				int tmp = array[j];
				array[j] = array[i];
				array[i] = tmp;

				Arrays.sort(array, i+1, end);

				return true;
			}
		}

		return false;
	}
}