import java.util.Scanner;

public class Main {
	
	static int[] dish = new int[5];
	static int[] last1 = new int[5];
	static String[] dishStr = new String[5];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int i=0; i<5; i++) {
			dishStr[i] = (sc.nextLine());
			dish[i] = Integer.parseInt(dishStr[i]);
		}
		
		int lastDish = 0;
		int mini1 = 0;
		//最後に、下一桁の数値が一番小さいdishを頼む(0を除く)
		for(int i=0; i<5; i++) {
			last1[i] = Integer.parseInt(dishStr[i].substring(dishStr[i].length() -1 , dishStr[i].length()));
			if(i == 0) {
				mini1 = last1[i];
				continue;
			}
			if(!(last1[i] == 0) && last1[i] < mini1) {
				mini1 = last1[i];
				lastDish = i;
			}
		}
		
		int ans = 0;
		for(int i=0; i<5; i++) {
			if(i==lastDish) {
				ans += dish[i];
			} else {
				if(last1[i] == 0) {
					ans += dish[i] + last1[i];
				}else {
					ans += dish[i] + 10 - last1[i];
				}
			}
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	
	static int[] dish = new int[5];
	static int[] last1 = new int[5];
	static String[] dishStr = new String[5];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int i=0; i<5; i++) {
			dishStr[i] = (sc.nextLine());
			dish[i] = Integer.parseInt(dishStr[i]);
		}
		
		int lastDish = 0;
		int mini1 = 0;
		//最後に、下一桁の数値が一番小さいdishを頼む(0を除く)
		for(int i=0; i<5; i++) {
			last1[i] = Integer.parseInt(dishStr[i].substring(dishStr[i].length() -1 , dishStr[i].length()));
			if(i == 0) {
				mini1 = last1[i];
				continue;
			}
			if(!(last1[i] == 0) && last1[i] < mini1) {
				mini1 = last1[i];
				lastDish = i;
			}
		}
		
		int ans = 0;
		for(int i=0; i<5; i++) {
			if(i==lastDish) {
				ans += dish[i];
			} else {
				if(last1[i] == 0) {
					ans += dish[i] + last1[i];
				}else {
					ans += dish[i] + 10 - last1[i];
				}
			}
		}
		System.out.println(ans);
	}
} Main static int[] dish = new int[5]; dish new int[5] 5 static int[] last1 = new int[5]; last1 new int[5] 5 static String[] dishStr = new String[5]; dishStr new String[5] 5 public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int i=0; i<5; i++) {
			dishStr[i] = (sc.nextLine());
			dish[i] = Integer.parseInt(dishStr[i]);
		}
		
		int lastDish = 0;
		int mini1 = 0;
		//最後に、下一桁の数値が一番小さいdishを頼む(0を除く)
		for(int i=0; i<5; i++) {
			last1[i] = Integer.parseInt(dishStr[i].substring(dishStr[i].length() -1 , dishStr[i].length()));
			if(i == 0) {
				mini1 = last1[i];
				continue;
			}
			if(!(last1[i] == 0) && last1[i] < mini1) {
				mini1 = last1[i];
				lastDish = i;
			}
		}
		
		int ans = 0;
		for(int i=0; i<5; i++) {
			if(i==lastDish) {
				ans += dish[i];
			} else {
				if(last1[i] == 0) {
					ans += dish[i] + last1[i];
				}else {
					ans += dish[i] + 10 - last1[i];
				}
			}
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		for(int i=0; i<5; i++) {
			dishStr[i] = (sc.nextLine());
			dish[i] = Integer.parseInt(dishStr[i]);
		}
		
		int lastDish = 0;
		int mini1 = 0;
		//最後に、下一桁の数値が一番小さいdishを頼む(0を除く)
		for(int i=0; i<5; i++) {
			last1[i] = Integer.parseInt(dishStr[i].substring(dishStr[i].length() -1 , dishStr[i].length()));
			if(i == 0) {
				mini1 = last1[i];
				continue;
			}
			if(!(last1[i] == 0) && last1[i] < mini1) {
				mini1 = last1[i];
				lastDish = i;
			}
		}
		
		int ans = 0;
		for(int i=0; i<5; i++) {
			if(i==lastDish) {
				ans += dish[i];
			} else {
				if(last1[i] == 0) {
					ans += dish[i] + last1[i];
				}else {
					ans += dish[i] + 10 - last1[i];
				}
			}
		}
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) for(int i=0; i<5; i++) {
			dishStr[i] = (sc.nextLine());
			dish[i] = Integer.parseInt(dishStr[i]);
		} int i=0; int i=0; i 0 i<5 i 5 i++ i++ i {
			dishStr[i] = (sc.nextLine());
			dish[i] = Integer.parseInt(dishStr[i]);
		} {
			dishStr[i] = (sc.nextLine());
			dish[i] = Integer.parseInt(dishStr[i]);
		} dishStr[i] = (sc.nextLine()) dishStr[i] dishStr i (sc.nextLine()) sc.nextLine sc dish[i] = Integer.parseInt(dishStr[i]) dish[i] dish i Integer.parseInt(dishStr[i]) Integer.parseInt Integer dishStr[i] dishStr i int lastDish = 0; lastDish 0 int mini1 = 0; mini1 0 for(int i=0; i<5; i++) {
			last1[i] = Integer.parseInt(dishStr[i].substring(dishStr[i].length() -1 , dishStr[i].length()));
			if(i == 0) {
				mini1 = last1[i];
				continue;
			}
			if(!(last1[i] == 0) && last1[i] < mini1) {
				mini1 = last1[i];
				lastDish = i;
			}
		} int i=0; int i=0; i 0 i<5 i 5 i++ i++ i {
			last1[i] = Integer.parseInt(dishStr[i].substring(dishStr[i].length() -1 , dishStr[i].length()));
			if(i == 0) {
				mini1 = last1[i];
				continue;
			}
			if(!(last1[i] == 0) && last1[i] < mini1) {
				mini1 = last1[i];
				lastDish = i;
			}
		} {
			last1[i] = Integer.parseInt(dishStr[i].substring(dishStr[i].length() -1 , dishStr[i].length()));
			if(i == 0) {
				mini1 = last1[i];
				continue;
			}
			if(!(last1[i] == 0) && last1[i] < mini1) {
				mini1 = last1[i];
				lastDish = i;
			}
		} last1[i] = Integer.parseInt(dishStr[i].substring(dishStr[i].length() -1 , dishStr[i].length())) last1[i] last1 i Integer.parseInt(dishStr[i].substring(dishStr[i].length() -1 , dishStr[i].length())) Integer.parseInt Integer dishStr[i].substring(dishStr[i].length() -1 , dishStr[i].length()) dishStr[i].substring dishStr[i] dishStr i dishStr[i].length() -1 dishStr[i].length() dishStr[i].length dishStr[i] dishStr i 1 dishStr[i].length() dishStr[i].length dishStr[i] dishStr i if(i == 0) {
				mini1 = last1[i];
				continue;
			} i == 0 i 0 {
				mini1 = last1[i];
				continue;
			} mini1 = last1[i] mini1 last1[i] last1 i continue; if(!(last1[i] == 0) && last1[i] < mini1) {
				mini1 = last1[i];
				lastDish = i;
			} !(last1[i] == 0) && last1[i] < mini1 !(last1[i] == 0) (last1[i] == 0) last1[i] last1 i 0 last1[i] < mini1 last1[i] last1 i mini1 {
				mini1 = last1[i];
				lastDish = i;
			} mini1 = last1[i] mini1 last1[i] last1 i lastDish = i lastDish i int ans = 0; ans 0 for(int i=0; i<5; i++) {
			if(i==lastDish) {
				ans += dish[i];
			} else {
				if(last1[i] == 0) {
					ans += dish[i] + last1[i];
				}else {
					ans += dish[i] + 10 - last1[i];
				}
			}
		} int i=0; int i=0; i 0 i<5 i 5 i++ i++ i {
			if(i==lastDish) {
				ans += dish[i];
			} else {
				if(last1[i] == 0) {
					ans += dish[i] + last1[i];
				}else {
					ans += dish[i] + 10 - last1[i];
				}
			}
		} {
			if(i==lastDish) {
				ans += dish[i];
			} else {
				if(last1[i] == 0) {
					ans += dish[i] + last1[i];
				}else {
					ans += dish[i] + 10 - last1[i];
				}
			}
		} if(i==lastDish) {
				ans += dish[i];
			} else {
				if(last1[i] == 0) {
					ans += dish[i] + last1[i];
				}else {
					ans += dish[i] + 10 - last1[i];
				}
			} i==lastDish i lastDish {
				ans += dish[i];
			} ans += dish[i] ans dish[i] dish i {
				if(last1[i] == 0) {
					ans += dish[i] + last1[i];
				}else {
					ans += dish[i] + 10 - last1[i];
				}
			} if(last1[i] == 0) {
					ans += dish[i] + last1[i];
				}else {
					ans += dish[i] + 10 - last1[i];
				} last1[i] == 0 last1[i] last1 i 0 {
					ans += dish[i] + last1[i];
				} ans += dish[i] + last1[i] ans dish[i] + last1[i] dish[i] dish i last1[i] last1 i {
					ans += dish[i] + 10 - last1[i];
				} ans += dish[i] + 10 - last1[i] ans dish[i] + 10 - last1[i] dish[i] + 10 dish[i] dish i 10 last1[i] last1 i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	
	static int[] dish = new int[5];
	static int[] last1 = new int[5];
	static String[] dishStr = new String[5];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int i=0; i<5; i++) {
			dishStr[i] = (sc.nextLine());
			dish[i] = Integer.parseInt(dishStr[i]);
		}
		
		int lastDish = 0;
		int mini1 = 0;
		//最後に、下一桁の数値が一番小さいdishを頼む(0を除く)
		for(int i=0; i<5; i++) {
			last1[i] = Integer.parseInt(dishStr[i].substring(dishStr[i].length() -1 , dishStr[i].length()));
			if(i == 0) {
				mini1 = last1[i];
				continue;
			}
			if(!(last1[i] == 0) && last1[i] < mini1) {
				mini1 = last1[i];
				lastDish = i;
			}
		}
		
		int ans = 0;
		for(int i=0; i<5; i++) {
			if(i==lastDish) {
				ans += dish[i];
			} else {
				if(last1[i] == 0) {
					ans += dish[i] + last1[i];
				}else {
					ans += dish[i] + 10 - last1[i];
				}
			}
		}
		System.out.println(ans);
	}
} public class Main {
	
	static int[] dish = new int[5];
	static int[] last1 = new int[5];
	static String[] dishStr = new String[5];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int i=0; i<5; i++) {
			dishStr[i] = (sc.nextLine());
			dish[i] = Integer.parseInt(dishStr[i]);
		}
		
		int lastDish = 0;
		int mini1 = 0;
		//最後に、下一桁の数値が一番小さいdishを頼む(0を除く)
		for(int i=0; i<5; i++) {
			last1[i] = Integer.parseInt(dishStr[i].substring(dishStr[i].length() -1 , dishStr[i].length()));
			if(i == 0) {
				mini1 = last1[i];
				continue;
			}
			if(!(last1[i] == 0) && last1[i] < mini1) {
				mini1 = last1[i];
				lastDish = i;
			}
		}
		
		int ans = 0;
		for(int i=0; i<5; i++) {
			if(i==lastDish) {
				ans += dish[i];
			} else {
				if(last1[i] == 0) {
					ans += dish[i] + last1[i];
				}else {
					ans += dish[i] + 10 - last1[i];
				}
			}
		}
		System.out.println(ans);
	}
} Main
import java.util.Scanner;

public class Main {
	
	static int[] dish = new int[5];
	static int[] last1 = new int[5];
	static String[] dishStr = new String[5];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int i=0; i<5; i++) {
			dishStr[i] = (sc.nextLine());
			dish[i] = Integer.parseInt(dishStr[i]);
		}
		
		int lastDish = 0;
		int mini1 = 0;
		//最後に、下一桁の数値が一番小さいdishを頼む(0を除く)
		for(int i=0; i<5; i++) {
			last1[i] = Integer.parseInt(dishStr[i].substring(dishStr[i].length() -1 , dishStr[i].length()));
			if(i == 0) {
				mini1 = last1[i];
				continue;
			}
			if(!(last1[i] == 0) && last1[i] < mini1) {
				mini1 = last1[i];
				lastDish = i;
			}
		}
		
		int ans = 0;
		for(int i=0; i<5; i++) {
			if(i==lastDish) {
				ans += dish[i];
			} else {
				if(last1[i] == 0) {
					ans += dish[i] + last1[i];
				}else {
					ans += dish[i] + 10 - last1[i];
				}
			}
		}
		System.out.println(ans);
	}
}