import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
    	int ans = Integer.MAX_VALUE;
    	
        void solve(InputReader in, PrintWriter out) {
        	Integer[] menu = {
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt()
        	};
        	PatternUtils<Integer> pt = new PatternUtils<>(Arrays.asList(menu));
        	
        	for (Object[] list : pt.permutation(5)) {
        		int fin = 0;
        		for (Object t : list) {
        			fin += (10 - fin % 10) % 10 + (Integer)t;
        		}
        		ans = Math.min(fin, ans);
        	}
        	
        	out.println(ans);
        }
    }
    
    static class PatternUtils<E> {
		private int[] indexes;
		private List<E> original;
		private List<Object[]> pattern;
		
		public PatternUtils(List<E> l) {
			this.original = l;
			this.indexes = new int[original.size()];
			for (int i = 0; i < original.size(); ++i) indexes[i] = i;
		}
		
		void search(int[] perm, Object[] items, int rem) {
			if (rem == 0 || perm.length == 0) {
				pattern.add(items);
			} else {
				int[] nperm = Arrays.copyOfRange(perm, 1, perm.length);
				
				int len = items.length + 1;
				Object[] nitems = Arrays.copyOfRange(items, 0, len);
 				for (int i = 0; i < perm.length; ++i) {
 					nitems[len - 1] = original.get(perm[i]);
					search(nperm, nitems, rem - 1);
					if (i < nperm.length) nperm[i] = perm[i];
				}
			}
		}
		
		List<Object[]> permutation(int n) {
			pattern = new ArrayList<>();
			
			search(indexes, new Object[0], n);
			
			return pattern;
		}
    }
    
    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() { return Integer.parseInt(next()); }

        long nextLong() { return Long.parseLong(next()); }

        long[] nextLongArray(int n) {
        	long[] arr = new long[n];
        	for (int i = 0; i < n; ++i) {
        		arr[i] = nextLong();
        	}
        	return arr;
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.OutputStream; OutputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.List; List java.util import java.util.StringTokenizer; StringTokenizer java.util class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
    	int ans = Integer.MAX_VALUE;
    	
        void solve(InputReader in, PrintWriter out) {
        	Integer[] menu = {
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt()
        	};
        	PatternUtils<Integer> pt = new PatternUtils<>(Arrays.asList(menu));
        	
        	for (Object[] list : pt.permutation(5)) {
        		int fin = 0;
        		for (Object t : list) {
        			fin += (10 - fin % 10) % 10 + (Integer)t;
        		}
        		ans = Math.min(fin, ans);
        	}
        	
        	out.println(ans);
        }
    }
    
    static class PatternUtils<E> {
		private int[] indexes;
		private List<E> original;
		private List<Object[]> pattern;
		
		public PatternUtils(List<E> l) {
			this.original = l;
			this.indexes = new int[original.size()];
			for (int i = 0; i < original.size(); ++i) indexes[i] = i;
		}
		
		void search(int[] perm, Object[] items, int rem) {
			if (rem == 0 || perm.length == 0) {
				pattern.add(items);
			} else {
				int[] nperm = Arrays.copyOfRange(perm, 1, perm.length);
				
				int len = items.length + 1;
				Object[] nitems = Arrays.copyOfRange(items, 0, len);
 				for (int i = 0; i < perm.length; ++i) {
 					nitems[len - 1] = original.get(perm[i]);
					search(nperm, nitems, rem - 1);
					if (i < nperm.length) nperm[i] = perm[i];
				}
			}
		}
		
		List<Object[]> permutation(int n) {
			pattern = new ArrayList<>();
			
			search(indexes, new Object[0], n);
			
			return pattern;
		}
    }
    
    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() { return Integer.parseInt(next()); }

        long nextLong() { return Long.parseLong(next()); }

        long[] nextLongArray(int n) {
        	long[] arr = new long[n];
        	for (int i = 0; i < n; ++i) {
        		arr[i] = nextLong();
        	}
        	return arr;
        }
    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out InputReader in = new InputReader(inputStream); in new InputReader(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) Task solver = new Task(); solver new Task() solver.solve(in, out) solver.solve solver in out out.close() out.close out String[] args args static class Task {
    	int ans = Integer.MAX_VALUE;
    	
        void solve(InputReader in, PrintWriter out) {
        	Integer[] menu = {
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt()
        	};
        	PatternUtils<Integer> pt = new PatternUtils<>(Arrays.asList(menu));
        	
        	for (Object[] list : pt.permutation(5)) {
        		int fin = 0;
        		for (Object t : list) {
        			fin += (10 - fin % 10) % 10 + (Integer)t;
        		}
        		ans = Math.min(fin, ans);
        	}
        	
        	out.println(ans);
        }
    } Task int ans = Integer.MAX_VALUE; ans Integer.MAX_VALUE Integer Integer.MAX_VALUE void solve(InputReader in, PrintWriter out) {
        	Integer[] menu = {
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt()
        	};
        	PatternUtils<Integer> pt = new PatternUtils<>(Arrays.asList(menu));
        	
        	for (Object[] list : pt.permutation(5)) {
        		int fin = 0;
        		for (Object t : list) {
        			fin += (10 - fin % 10) % 10 + (Integer)t;
        		}
        		ans = Math.min(fin, ans);
        	}
        	
        	out.println(ans);
        } solve {
        	Integer[] menu = {
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt()
        	};
        	PatternUtils<Integer> pt = new PatternUtils<>(Arrays.asList(menu));
        	
        	for (Object[] list : pt.permutation(5)) {
        		int fin = 0;
        		for (Object t : list) {
        			fin += (10 - fin % 10) % 10 + (Integer)t;
        		}
        		ans = Math.min(fin, ans);
        	}
        	
        	out.println(ans);
        } Integer[] menu = {
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt()
        	}; menu {
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt()
        	} in.nextInt() in.nextInt in in.nextInt() in.nextInt in in.nextInt() in.nextInt in in.nextInt() in.nextInt in in.nextInt() in.nextInt in PatternUtils<Integer> pt = new PatternUtils<>(Arrays.asList(menu)); pt new PatternUtils<>(Arrays.asList(menu)) for (Object[] list : pt.permutation(5)) {
        		int fin = 0;
        		for (Object t : list) {
        			fin += (10 - fin % 10) % 10 + (Integer)t;
        		}
        		ans = Math.min(fin, ans);
        	} Object[] list pt.permutation(5) pt.permutation pt 5 {
        		int fin = 0;
        		for (Object t : list) {
        			fin += (10 - fin % 10) % 10 + (Integer)t;
        		}
        		ans = Math.min(fin, ans);
        	} {
        		int fin = 0;
        		for (Object t : list) {
        			fin += (10 - fin % 10) % 10 + (Integer)t;
        		}
        		ans = Math.min(fin, ans);
        	} int fin = 0; fin 0 for (Object t : list) {
        			fin += (10 - fin % 10) % 10 + (Integer)t;
        		} Object t list {
        			fin += (10 - fin % 10) % 10 + (Integer)t;
        		} {
        			fin += (10 - fin % 10) % 10 + (Integer)t;
        		} fin += (10 - fin % 10) % 10 + (Integer)t fin (10 - fin % 10) % 10 + (Integer)t (10 - fin % 10) % 10 (10 - fin % 10) 10 fin % 10 fin 10 10 (Integer)t ans = Math.min(fin, ans) ans Math.min(fin, ans) Math.min Math fin ans out.println(ans) out.println out ans InputReader in in PrintWriter out out static class PatternUtils<E> {
		private int[] indexes;
		private List<E> original;
		private List<Object[]> pattern;
		
		public PatternUtils(List<E> l) {
			this.original = l;
			this.indexes = new int[original.size()];
			for (int i = 0; i < original.size(); ++i) indexes[i] = i;
		}
		
		void search(int[] perm, Object[] items, int rem) {
			if (rem == 0 || perm.length == 0) {
				pattern.add(items);
			} else {
				int[] nperm = Arrays.copyOfRange(perm, 1, perm.length);
				
				int len = items.length + 1;
				Object[] nitems = Arrays.copyOfRange(items, 0, len);
 				for (int i = 0; i < perm.length; ++i) {
 					nitems[len - 1] = original.get(perm[i]);
					search(nperm, nitems, rem - 1);
					if (i < nperm.length) nperm[i] = perm[i];
				}
			}
		}
		
		List<Object[]> permutation(int n) {
			pattern = new ArrayList<>();
			
			search(indexes, new Object[0], n);
			
			return pattern;
		}
    } PatternUtils private int[] indexes; indexes private List<E> original; original private List<Object[]> pattern; pattern public PatternUtils(List<E> l) {
			this.original = l;
			this.indexes = new int[original.size()];
			for (int i = 0; i < original.size(); ++i) indexes[i] = i;
		} PatternUtils {
			this.original = l;
			this.indexes = new int[original.size()];
			for (int i = 0; i < original.size(); ++i) indexes[i] = i;
		} this.original = l this.original this this.original l this.indexes = new int[original.size()] this.indexes this this.indexes new int[original.size()] original.size() original.size original for (int i = 0; i < original.size(); ++i) indexes[i] = i; int i = 0; int i = 0; i 0 i < original.size() i original.size() original.size original ++i ++i i indexes[i] = i; indexes[i] = i indexes[i] indexes i i List<E> l l void search(int[] perm, Object[] items, int rem) {
			if (rem == 0 || perm.length == 0) {
				pattern.add(items);
			} else {
				int[] nperm = Arrays.copyOfRange(perm, 1, perm.length);
				
				int len = items.length + 1;
				Object[] nitems = Arrays.copyOfRange(items, 0, len);
 				for (int i = 0; i < perm.length; ++i) {
 					nitems[len - 1] = original.get(perm[i]);
					search(nperm, nitems, rem - 1);
					if (i < nperm.length) nperm[i] = perm[i];
				}
			}
		} search {
			if (rem == 0 || perm.length == 0) {
				pattern.add(items);
			} else {
				int[] nperm = Arrays.copyOfRange(perm, 1, perm.length);
				
				int len = items.length + 1;
				Object[] nitems = Arrays.copyOfRange(items, 0, len);
 				for (int i = 0; i < perm.length; ++i) {
 					nitems[len - 1] = original.get(perm[i]);
					search(nperm, nitems, rem - 1);
					if (i < nperm.length) nperm[i] = perm[i];
				}
			}
		} if (rem == 0 || perm.length == 0) {
				pattern.add(items);
			} else {
				int[] nperm = Arrays.copyOfRange(perm, 1, perm.length);
				
				int len = items.length + 1;
				Object[] nitems = Arrays.copyOfRange(items, 0, len);
 				for (int i = 0; i < perm.length; ++i) {
 					nitems[len - 1] = original.get(perm[i]);
					search(nperm, nitems, rem - 1);
					if (i < nperm.length) nperm[i] = perm[i];
				}
			} rem == 0 || perm.length == 0 rem == 0 rem 0 perm.length == 0 perm.length perm perm.length 0 {
				pattern.add(items);
			} pattern.add(items) pattern.add pattern items {
				int[] nperm = Arrays.copyOfRange(perm, 1, perm.length);
				
				int len = items.length + 1;
				Object[] nitems = Arrays.copyOfRange(items, 0, len);
 				for (int i = 0; i < perm.length; ++i) {
 					nitems[len - 1] = original.get(perm[i]);
					search(nperm, nitems, rem - 1);
					if (i < nperm.length) nperm[i] = perm[i];
				}
			} int[] nperm = Arrays.copyOfRange(perm, 1, perm.length); nperm Arrays.copyOfRange(perm, 1, perm.length) Arrays.copyOfRange Arrays perm 1 perm.length perm perm.length int len = items.length + 1; len items.length + 1 items.length items items.length 1 Object[] nitems = Arrays.copyOfRange(items, 0, len); nitems Arrays.copyOfRange(items, 0, len) Arrays.copyOfRange Arrays items 0 len for (int i = 0; i < perm.length; ++i) {
 					nitems[len - 1] = original.get(perm[i]);
					search(nperm, nitems, rem - 1);
					if (i < nperm.length) nperm[i] = perm[i];
				} int i = 0; int i = 0; i 0 i < perm.length i perm.length perm perm.length ++i ++i i {
 					nitems[len - 1] = original.get(perm[i]);
					search(nperm, nitems, rem - 1);
					if (i < nperm.length) nperm[i] = perm[i];
				} {
 					nitems[len - 1] = original.get(perm[i]);
					search(nperm, nitems, rem - 1);
					if (i < nperm.length) nperm[i] = perm[i];
				} nitems[len - 1] = original.get(perm[i]) nitems[len - 1] nitems len - 1 len 1 original.get(perm[i]) original.get original perm[i] perm i search(nperm, nitems, rem - 1) search nperm nitems rem - 1 rem 1 if (i < nperm.length) nperm[i] = perm[i]; i < nperm.length i nperm.length nperm nperm.length nperm[i] = perm[i] nperm[i] nperm i perm[i] perm i int[] perm perm Object[] items items int rem rem List<Object[]> permutation(int n) {
			pattern = new ArrayList<>();
			
			search(indexes, new Object[0], n);
			
			return pattern;
		} permutation {
			pattern = new ArrayList<>();
			
			search(indexes, new Object[0], n);
			
			return pattern;
		} pattern = new ArrayList<>() pattern new ArrayList<>() search(indexes, new Object[0], n) search indexes new Object[0] 0 n return pattern; pattern int n n static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() { return Integer.parseInt(next()); }

        long nextLong() { return Long.parseLong(next()); }

        long[] nextLongArray(int n) {
        	long[] arr = new long[n];
        	for (int i = 0; i < n; ++i) {
        		arr[i] = nextLong();
        	}
        	return arr;
        }
    } InputReader BufferedReader reader; reader StringTokenizer tokenizer; tokenizer InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        } InputReader {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        } reader = new BufferedReader(new InputStreamReader(stream)) reader new BufferedReader(new InputStreamReader(stream)) tokenizer = null tokenizer null InputStream stream stream String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        } next {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        } while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } tokenizer == null || !tokenizer.hasMoreTokens() tokenizer == null tokenizer null !tokenizer.hasMoreTokens() tokenizer.hasMoreTokens() tokenizer.hasMoreTokens tokenizer {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            } try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                } IOException e {
                    throw new RuntimeException(e);
                } throw new RuntimeException(e); new RuntimeException(e) {
                    tokenizer = new StringTokenizer(reader.readLine());
                } tokenizer = new StringTokenizer(reader.readLine()) tokenizer new StringTokenizer(reader.readLine()) return tokenizer.nextToken(); tokenizer.nextToken() tokenizer.nextToken tokenizer int nextInt() { return Integer.parseInt(next()); } nextInt { return Integer.parseInt(next()); } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong() { return Long.parseLong(next()); } nextLong { return Long.parseLong(next()); } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next long[] nextLongArray(int n) {
        	long[] arr = new long[n];
        	for (int i = 0; i < n; ++i) {
        		arr[i] = nextLong();
        	}
        	return arr;
        } nextLongArray {
        	long[] arr = new long[n];
        	for (int i = 0; i < n; ++i) {
        		arr[i] = nextLong();
        	}
        	return arr;
        } long[] arr = new long[n]; arr new long[n] n for (int i = 0; i < n; ++i) {
        		arr[i] = nextLong();
        	} int i = 0; int i = 0; i 0 i < n i n ++i ++i i {
        		arr[i] = nextLong();
        	} {
        		arr[i] = nextLong();
        	} arr[i] = nextLong() arr[i] arr i nextLong() nextLong return arr; arr int n n
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
    	int ans = Integer.MAX_VALUE;
    	
        void solve(InputReader in, PrintWriter out) {
        	Integer[] menu = {
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt(),
        		in.nextInt()
        	};
        	PatternUtils<Integer> pt = new PatternUtils<>(Arrays.asList(menu));
        	
        	for (Object[] list : pt.permutation(5)) {
        		int fin = 0;
        		for (Object t : list) {
        			fin += (10 - fin % 10) % 10 + (Integer)t;
        		}
        		ans = Math.min(fin, ans);
        	}
        	
        	out.println(ans);
        }
    }
    
    static class PatternUtils<E> {
		private int[] indexes;
		private List<E> original;
		private List<Object[]> pattern;
		
		public PatternUtils(List<E> l) {
			this.original = l;
			this.indexes = new int[original.size()];
			for (int i = 0; i < original.size(); ++i) indexes[i] = i;
		}
		
		void search(int[] perm, Object[] items, int rem) {
			if (rem == 0 || perm.length == 0) {
				pattern.add(items);
			} else {
				int[] nperm = Arrays.copyOfRange(perm, 1, perm.length);
				
				int len = items.length + 1;
				Object[] nitems = Arrays.copyOfRange(items, 0, len);
 				for (int i = 0; i < perm.length; ++i) {
 					nitems[len - 1] = original.get(perm[i]);
					search(nperm, nitems, rem - 1);
					if (i < nperm.length) nperm[i] = perm[i];
				}
			}
		}
		
		List<Object[]> permutation(int n) {
			pattern = new ArrayList<>();
			
			search(indexes, new Object[0], n);
			
			return pattern;
		}
    }
    
    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() { return Integer.parseInt(next()); }

        long nextLong() { return Long.parseLong(next()); }

        long[] nextLongArray(int n) {
        	long[] arr = new long[n];
        	for (int i = 0; i < n; ++i) {
        		arr[i] = nextLong();
        	}
        	return arr;
        }
    }
}
