// package abc123.B;

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] times = new int[5];
        for (int i = 0; i < 5; i += 1) {
            times[i] = sc.nextInt();
        }

        Integer[] indices = new Integer[5];
        for (int i = 0; i < 5; i += 1) {
            indices[i] = i;
        }
        List<List<Integer>> perms = permute(indices);

        int minTime = Integer.MAX_VALUE;
        for (List<Integer> perm : perms) {
            int time = 0;
            for (int index : perm) {
                if (time % 10 != 0) {
                    time += 10 - (time % 10);
                }
                time += times[index];
            }
            if (minTime > time) {
                minTime = time;
            }
        }

        System.out.println(minTime);
    }

    private static <T> List<List<T>> permute(T[] items) {
        List<List<T>> perms = new LinkedList<>();
        permuteHelper(perms, items, 0);
        return perms;
    }

    private static <T> void permuteHelper(List<List<T>> perms, T[] items, int n) {
        if (n == items.length - 1) {
            List<T> perm = new LinkedList<>();
            for (T item : items) {
                perm.add(item);
            }
            perms.add(perm);
        } else {
            for (int m = n; m < items.length; m += 1) {
                swap(items, n, m);
                permuteHelper(perms, items, n + 1);
                swap(items, n, m);
            }
        }
    }

    private static <T> void swap(T[] items, int index1, int index2) {
        T tmp = items[index1];
        items[index1] = items[index2];
        items[index2] = tmp;
    }

} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] times = new int[5];
        for (int i = 0; i < 5; i += 1) {
            times[i] = sc.nextInt();
        }

        Integer[] indices = new Integer[5];
        for (int i = 0; i < 5; i += 1) {
            indices[i] = i;
        }
        List<List<Integer>> perms = permute(indices);

        int minTime = Integer.MAX_VALUE;
        for (List<Integer> perm : perms) {
            int time = 0;
            for (int index : perm) {
                if (time % 10 != 0) {
                    time += 10 - (time % 10);
                }
                time += times[index];
            }
            if (minTime > time) {
                minTime = time;
            }
        }

        System.out.println(minTime);
    }

    private static <T> List<List<T>> permute(T[] items) {
        List<List<T>> perms = new LinkedList<>();
        permuteHelper(perms, items, 0);
        return perms;
    }

    private static <T> void permuteHelper(List<List<T>> perms, T[] items, int n) {
        if (n == items.length - 1) {
            List<T> perm = new LinkedList<>();
            for (T item : items) {
                perm.add(item);
            }
            perms.add(perm);
        } else {
            for (int m = n; m < items.length; m += 1) {
                swap(items, n, m);
                permuteHelper(perms, items, n + 1);
                swap(items, n, m);
            }
        }
    }

    private static <T> void swap(T[] items, int index1, int index2) {
        T tmp = items[index1];
        items[index1] = items[index2];
        items[index2] = tmp;
    }

} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] times = new int[5];
        for (int i = 0; i < 5; i += 1) {
            times[i] = sc.nextInt();
        }

        Integer[] indices = new Integer[5];
        for (int i = 0; i < 5; i += 1) {
            indices[i] = i;
        }
        List<List<Integer>> perms = permute(indices);

        int minTime = Integer.MAX_VALUE;
        for (List<Integer> perm : perms) {
            int time = 0;
            for (int index : perm) {
                if (time % 10 != 0) {
                    time += 10 - (time % 10);
                }
                time += times[index];
            }
            if (minTime > time) {
                minTime = time;
            }
        }

        System.out.println(minTime);
    } main {
        Scanner sc = new Scanner(System.in);
        int[] times = new int[5];
        for (int i = 0; i < 5; i += 1) {
            times[i] = sc.nextInt();
        }

        Integer[] indices = new Integer[5];
        for (int i = 0; i < 5; i += 1) {
            indices[i] = i;
        }
        List<List<Integer>> perms = permute(indices);

        int minTime = Integer.MAX_VALUE;
        for (List<Integer> perm : perms) {
            int time = 0;
            for (int index : perm) {
                if (time % 10 != 0) {
                    time += 10 - (time % 10);
                }
                time += times[index];
            }
            if (minTime > time) {
                minTime = time;
            }
        }

        System.out.println(minTime);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int[] times = new int[5]; times new int[5] 5 for (int i = 0; i < 5; i += 1) {
            times[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < 5 i 5 i += 1 i += 1 i 1 {
            times[i] = sc.nextInt();
        } {
            times[i] = sc.nextInt();
        } times[i] = sc.nextInt() times[i] times i sc.nextInt() sc.nextInt sc Integer[] indices = new Integer[5]; indices new Integer[5] 5 for (int i = 0; i < 5; i += 1) {
            indices[i] = i;
        } int i = 0; int i = 0; i 0 i < 5 i 5 i += 1 i += 1 i 1 {
            indices[i] = i;
        } {
            indices[i] = i;
        } indices[i] = i indices[i] indices i i List<List<Integer>> perms = permute(indices); perms permute(indices) permute indices int minTime = Integer.MAX_VALUE; minTime Integer.MAX_VALUE Integer Integer.MAX_VALUE for (List<Integer> perm : perms) {
            int time = 0;
            for (int index : perm) {
                if (time % 10 != 0) {
                    time += 10 - (time % 10);
                }
                time += times[index];
            }
            if (minTime > time) {
                minTime = time;
            }
        } List<Integer> perm perms {
            int time = 0;
            for (int index : perm) {
                if (time % 10 != 0) {
                    time += 10 - (time % 10);
                }
                time += times[index];
            }
            if (minTime > time) {
                minTime = time;
            }
        } {
            int time = 0;
            for (int index : perm) {
                if (time % 10 != 0) {
                    time += 10 - (time % 10);
                }
                time += times[index];
            }
            if (minTime > time) {
                minTime = time;
            }
        } int time = 0; time 0 for (int index : perm) {
                if (time % 10 != 0) {
                    time += 10 - (time % 10);
                }
                time += times[index];
            } int index perm {
                if (time % 10 != 0) {
                    time += 10 - (time % 10);
                }
                time += times[index];
            } {
                if (time % 10 != 0) {
                    time += 10 - (time % 10);
                }
                time += times[index];
            } if (time % 10 != 0) {
                    time += 10 - (time % 10);
                } time % 10 != 0 time % 10 time 10 0 {
                    time += 10 - (time % 10);
                } time += 10 - (time % 10) time 10 - (time % 10) 10 (time % 10) time 10 time += times[index] time times[index] times index if (minTime > time) {
                minTime = time;
            } minTime > time minTime time {
                minTime = time;
            } minTime = time minTime time System.out.println(minTime) System.out.println System.out System System.out minTime String[] args args private static <T> List<List<T>> permute(T[] items) {
        List<List<T>> perms = new LinkedList<>();
        permuteHelper(perms, items, 0);
        return perms;
    } permute {
        List<List<T>> perms = new LinkedList<>();
        permuteHelper(perms, items, 0);
        return perms;
    } List<List<T>> perms = new LinkedList<>(); perms new LinkedList<>() permuteHelper(perms, items, 0) permuteHelper perms items 0 return perms; perms T[] items items private static <T> void permuteHelper(List<List<T>> perms, T[] items, int n) {
        if (n == items.length - 1) {
            List<T> perm = new LinkedList<>();
            for (T item : items) {
                perm.add(item);
            }
            perms.add(perm);
        } else {
            for (int m = n; m < items.length; m += 1) {
                swap(items, n, m);
                permuteHelper(perms, items, n + 1);
                swap(items, n, m);
            }
        }
    } permuteHelper {
        if (n == items.length - 1) {
            List<T> perm = new LinkedList<>();
            for (T item : items) {
                perm.add(item);
            }
            perms.add(perm);
        } else {
            for (int m = n; m < items.length; m += 1) {
                swap(items, n, m);
                permuteHelper(perms, items, n + 1);
                swap(items, n, m);
            }
        }
    } if (n == items.length - 1) {
            List<T> perm = new LinkedList<>();
            for (T item : items) {
                perm.add(item);
            }
            perms.add(perm);
        } else {
            for (int m = n; m < items.length; m += 1) {
                swap(items, n, m);
                permuteHelper(perms, items, n + 1);
                swap(items, n, m);
            }
        } n == items.length - 1 n items.length - 1 items.length items items.length 1 {
            List<T> perm = new LinkedList<>();
            for (T item : items) {
                perm.add(item);
            }
            perms.add(perm);
        } List<T> perm = new LinkedList<>(); perm new LinkedList<>() for (T item : items) {
                perm.add(item);
            } T item items {
                perm.add(item);
            } {
                perm.add(item);
            } perm.add(item) perm.add perm item perms.add(perm) perms.add perms perm {
            for (int m = n; m < items.length; m += 1) {
                swap(items, n, m);
                permuteHelper(perms, items, n + 1);
                swap(items, n, m);
            }
        } for (int m = n; m < items.length; m += 1) {
                swap(items, n, m);
                permuteHelper(perms, items, n + 1);
                swap(items, n, m);
            } int m = n; int m = n; m n m < items.length m items.length items items.length m += 1 m += 1 m 1 {
                swap(items, n, m);
                permuteHelper(perms, items, n + 1);
                swap(items, n, m);
            } {
                swap(items, n, m);
                permuteHelper(perms, items, n + 1);
                swap(items, n, m);
            } swap(items, n, m) swap items n m permuteHelper(perms, items, n + 1) permuteHelper perms items n + 1 n 1 swap(items, n, m) swap items n m List<List<T>> perms perms T[] items items int n n private static <T> void swap(T[] items, int index1, int index2) {
        T tmp = items[index1];
        items[index1] = items[index2];
        items[index2] = tmp;
    } swap {
        T tmp = items[index1];
        items[index1] = items[index2];
        items[index2] = tmp;
    } T tmp = items[index1]; tmp items[index1] items index1 items[index1] = items[index2] items[index1] items index1 items[index2] items index2 items[index2] = tmp items[index2] items index2 tmp T[] items items int index1 index1 int index2 index2 public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] times = new int[5];
        for (int i = 0; i < 5; i += 1) {
            times[i] = sc.nextInt();
        }

        Integer[] indices = new Integer[5];
        for (int i = 0; i < 5; i += 1) {
            indices[i] = i;
        }
        List<List<Integer>> perms = permute(indices);

        int minTime = Integer.MAX_VALUE;
        for (List<Integer> perm : perms) {
            int time = 0;
            for (int index : perm) {
                if (time % 10 != 0) {
                    time += 10 - (time % 10);
                }
                time += times[index];
            }
            if (minTime > time) {
                minTime = time;
            }
        }

        System.out.println(minTime);
    }

    private static <T> List<List<T>> permute(T[] items) {
        List<List<T>> perms = new LinkedList<>();
        permuteHelper(perms, items, 0);
        return perms;
    }

    private static <T> void permuteHelper(List<List<T>> perms, T[] items, int n) {
        if (n == items.length - 1) {
            List<T> perm = new LinkedList<>();
            for (T item : items) {
                perm.add(item);
            }
            perms.add(perm);
        } else {
            for (int m = n; m < items.length; m += 1) {
                swap(items, n, m);
                permuteHelper(perms, items, n + 1);
                swap(items, n, m);
            }
        }
    }

    private static <T> void swap(T[] items, int index1, int index2) {
        T tmp = items[index1];
        items[index1] = items[index2];
        items[index2] = tmp;
    }

} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] times = new int[5];
        for (int i = 0; i < 5; i += 1) {
            times[i] = sc.nextInt();
        }

        Integer[] indices = new Integer[5];
        for (int i = 0; i < 5; i += 1) {
            indices[i] = i;
        }
        List<List<Integer>> perms = permute(indices);

        int minTime = Integer.MAX_VALUE;
        for (List<Integer> perm : perms) {
            int time = 0;
            for (int index : perm) {
                if (time % 10 != 0) {
                    time += 10 - (time % 10);
                }
                time += times[index];
            }
            if (minTime > time) {
                minTime = time;
            }
        }

        System.out.println(minTime);
    }

    private static <T> List<List<T>> permute(T[] items) {
        List<List<T>> perms = new LinkedList<>();
        permuteHelper(perms, items, 0);
        return perms;
    }

    private static <T> void permuteHelper(List<List<T>> perms, T[] items, int n) {
        if (n == items.length - 1) {
            List<T> perm = new LinkedList<>();
            for (T item : items) {
                perm.add(item);
            }
            perms.add(perm);
        } else {
            for (int m = n; m < items.length; m += 1) {
                swap(items, n, m);
                permuteHelper(perms, items, n + 1);
                swap(items, n, m);
            }
        }
    }

    private static <T> void swap(T[] items, int index1, int index2) {
        T tmp = items[index1];
        items[index1] = items[index2];
        items[index2] = tmp;
    }

} Main
// package abc123.B;

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] times = new int[5];
        for (int i = 0; i < 5; i += 1) {
            times[i] = sc.nextInt();
        }

        Integer[] indices = new Integer[5];
        for (int i = 0; i < 5; i += 1) {
            indices[i] = i;
        }
        List<List<Integer>> perms = permute(indices);

        int minTime = Integer.MAX_VALUE;
        for (List<Integer> perm : perms) {
            int time = 0;
            for (int index : perm) {
                if (time % 10 != 0) {
                    time += 10 - (time % 10);
                }
                time += times[index];
            }
            if (minTime > time) {
                minTime = time;
            }
        }

        System.out.println(minTime);
    }

    private static <T> List<List<T>> permute(T[] items) {
        List<List<T>> perms = new LinkedList<>();
        permuteHelper(perms, items, 0);
        return perms;
    }

    private static <T> void permuteHelper(List<List<T>> perms, T[] items, int n) {
        if (n == items.length - 1) {
            List<T> perm = new LinkedList<>();
            for (T item : items) {
                perm.add(item);
            }
            perms.add(perm);
        } else {
            for (int m = n; m < items.length; m += 1) {
                swap(items, n, m);
                permuteHelper(perms, items, n + 1);
                swap(items, n, m);
            }
        }
    }

    private static <T> void swap(T[] items, int index1, int index2) {
        T tmp = items[index1];
        items[index1] = items[index2];
        items[index2] = tmp;
    }

}
