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

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int[] times = new int[5];
        for(int i = 0; i < 5; i++){
            times[i] = scan.nextInt();
        }

        // search
        int min = Integer.MAX_VALUE;
        for(int a = 0; a < 5; a++){
            int sum = times[a];
            if(sum % 10 != 0){
                sum +=10 - sum % 10;
            }
            for(int b = 0; b < 5; b++){
                if(b == a){
                    continue;
                }
                sum += times[b];
                int tempB = 0;
                if(sum % 10 != 0){
                    tempB = 10 - sum % 10;
                    sum += tempB;
                }
                for(int c = 0; c < 5; c++){
                    if(c == a || c == b){
                        continue;
                    }
                    sum += times[c];
                    int tempC = 0;
                    if(sum % 10 != 0){
                        tempC = 10 - sum % 10;
                        sum += tempC;
                    }
                    for(int d = 0; d < 5; d++){
                        if(d == a || d == b || d == c){
                            continue;
                        }
                        sum += times[d];
                        int tempD = 0;
                        if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        }
                        for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        }
                        sum -= (times[d] + tempD);
                    }
                    sum -= (times[c] + tempC);
                }
                sum -= (times[b] + tempB);
            }
        }


        // answer
        System.out.println(min);

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

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int[] times = new int[5];
        for(int i = 0; i < 5; i++){
            times[i] = scan.nextInt();
        }

        // search
        int min = Integer.MAX_VALUE;
        for(int a = 0; a < 5; a++){
            int sum = times[a];
            if(sum % 10 != 0){
                sum +=10 - sum % 10;
            }
            for(int b = 0; b < 5; b++){
                if(b == a){
                    continue;
                }
                sum += times[b];
                int tempB = 0;
                if(sum % 10 != 0){
                    tempB = 10 - sum % 10;
                    sum += tempB;
                }
                for(int c = 0; c < 5; c++){
                    if(c == a || c == b){
                        continue;
                    }
                    sum += times[c];
                    int tempC = 0;
                    if(sum % 10 != 0){
                        tempC = 10 - sum % 10;
                        sum += tempC;
                    }
                    for(int d = 0; d < 5; d++){
                        if(d == a || d == b || d == c){
                            continue;
                        }
                        sum += times[d];
                        int tempD = 0;
                        if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        }
                        for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        }
                        sum -= (times[d] + tempD);
                    }
                    sum -= (times[c] + tempC);
                }
                sum -= (times[b] + tempB);
            }
        }


        // answer
        System.out.println(min);

    }
} Main public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int[] times = new int[5];
        for(int i = 0; i < 5; i++){
            times[i] = scan.nextInt();
        }

        // search
        int min = Integer.MAX_VALUE;
        for(int a = 0; a < 5; a++){
            int sum = times[a];
            if(sum % 10 != 0){
                sum +=10 - sum % 10;
            }
            for(int b = 0; b < 5; b++){
                if(b == a){
                    continue;
                }
                sum += times[b];
                int tempB = 0;
                if(sum % 10 != 0){
                    tempB = 10 - sum % 10;
                    sum += tempB;
                }
                for(int c = 0; c < 5; c++){
                    if(c == a || c == b){
                        continue;
                    }
                    sum += times[c];
                    int tempC = 0;
                    if(sum % 10 != 0){
                        tempC = 10 - sum % 10;
                        sum += tempC;
                    }
                    for(int d = 0; d < 5; d++){
                        if(d == a || d == b || d == c){
                            continue;
                        }
                        sum += times[d];
                        int tempD = 0;
                        if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        }
                        for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        }
                        sum -= (times[d] + tempD);
                    }
                    sum -= (times[c] + tempC);
                }
                sum -= (times[b] + tempB);
            }
        }


        // answer
        System.out.println(min);

    } main {
        Scanner scan = new Scanner(System.in);

        // input
        int[] times = new int[5];
        for(int i = 0; i < 5; i++){
            times[i] = scan.nextInt();
        }

        // search
        int min = Integer.MAX_VALUE;
        for(int a = 0; a < 5; a++){
            int sum = times[a];
            if(sum % 10 != 0){
                sum +=10 - sum % 10;
            }
            for(int b = 0; b < 5; b++){
                if(b == a){
                    continue;
                }
                sum += times[b];
                int tempB = 0;
                if(sum % 10 != 0){
                    tempB = 10 - sum % 10;
                    sum += tempB;
                }
                for(int c = 0; c < 5; c++){
                    if(c == a || c == b){
                        continue;
                    }
                    sum += times[c];
                    int tempC = 0;
                    if(sum % 10 != 0){
                        tempC = 10 - sum % 10;
                        sum += tempC;
                    }
                    for(int d = 0; d < 5; d++){
                        if(d == a || d == b || d == c){
                            continue;
                        }
                        sum += times[d];
                        int tempD = 0;
                        if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        }
                        for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        }
                        sum -= (times[d] + tempD);
                    }
                    sum -= (times[c] + tempC);
                }
                sum -= (times[b] + tempB);
            }
        }


        // answer
        System.out.println(min);

    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int[] times = new int[5]; times new int[5] 5 for(int i = 0; i < 5; i++){
            times[i] = scan.nextInt();
        } int i = 0; int i = 0; i 0 i < 5 i 5 i++ i++ i {
            times[i] = scan.nextInt();
        } {
            times[i] = scan.nextInt();
        } times[i] = scan.nextInt() times[i] times i scan.nextInt() scan.nextInt scan int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int a = 0; a < 5; a++){
            int sum = times[a];
            if(sum % 10 != 0){
                sum +=10 - sum % 10;
            }
            for(int b = 0; b < 5; b++){
                if(b == a){
                    continue;
                }
                sum += times[b];
                int tempB = 0;
                if(sum % 10 != 0){
                    tempB = 10 - sum % 10;
                    sum += tempB;
                }
                for(int c = 0; c < 5; c++){
                    if(c == a || c == b){
                        continue;
                    }
                    sum += times[c];
                    int tempC = 0;
                    if(sum % 10 != 0){
                        tempC = 10 - sum % 10;
                        sum += tempC;
                    }
                    for(int d = 0; d < 5; d++){
                        if(d == a || d == b || d == c){
                            continue;
                        }
                        sum += times[d];
                        int tempD = 0;
                        if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        }
                        for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        }
                        sum -= (times[d] + tempD);
                    }
                    sum -= (times[c] + tempC);
                }
                sum -= (times[b] + tempB);
            }
        } int a = 0; int a = 0; a 0 a < 5 a 5 a++ a++ a {
            int sum = times[a];
            if(sum % 10 != 0){
                sum +=10 - sum % 10;
            }
            for(int b = 0; b < 5; b++){
                if(b == a){
                    continue;
                }
                sum += times[b];
                int tempB = 0;
                if(sum % 10 != 0){
                    tempB = 10 - sum % 10;
                    sum += tempB;
                }
                for(int c = 0; c < 5; c++){
                    if(c == a || c == b){
                        continue;
                    }
                    sum += times[c];
                    int tempC = 0;
                    if(sum % 10 != 0){
                        tempC = 10 - sum % 10;
                        sum += tempC;
                    }
                    for(int d = 0; d < 5; d++){
                        if(d == a || d == b || d == c){
                            continue;
                        }
                        sum += times[d];
                        int tempD = 0;
                        if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        }
                        for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        }
                        sum -= (times[d] + tempD);
                    }
                    sum -= (times[c] + tempC);
                }
                sum -= (times[b] + tempB);
            }
        } {
            int sum = times[a];
            if(sum % 10 != 0){
                sum +=10 - sum % 10;
            }
            for(int b = 0; b < 5; b++){
                if(b == a){
                    continue;
                }
                sum += times[b];
                int tempB = 0;
                if(sum % 10 != 0){
                    tempB = 10 - sum % 10;
                    sum += tempB;
                }
                for(int c = 0; c < 5; c++){
                    if(c == a || c == b){
                        continue;
                    }
                    sum += times[c];
                    int tempC = 0;
                    if(sum % 10 != 0){
                        tempC = 10 - sum % 10;
                        sum += tempC;
                    }
                    for(int d = 0; d < 5; d++){
                        if(d == a || d == b || d == c){
                            continue;
                        }
                        sum += times[d];
                        int tempD = 0;
                        if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        }
                        for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        }
                        sum -= (times[d] + tempD);
                    }
                    sum -= (times[c] + tempC);
                }
                sum -= (times[b] + tempB);
            }
        } int sum = times[a]; sum times[a] times a if(sum % 10 != 0){
                sum +=10 - sum % 10;
            } sum % 10 != 0 sum % 10 sum 10 0 {
                sum +=10 - sum % 10;
            } sum +=10 - sum % 10 sum 10 - sum % 10 10 sum % 10 sum 10 for(int b = 0; b < 5; b++){
                if(b == a){
                    continue;
                }
                sum += times[b];
                int tempB = 0;
                if(sum % 10 != 0){
                    tempB = 10 - sum % 10;
                    sum += tempB;
                }
                for(int c = 0; c < 5; c++){
                    if(c == a || c == b){
                        continue;
                    }
                    sum += times[c];
                    int tempC = 0;
                    if(sum % 10 != 0){
                        tempC = 10 - sum % 10;
                        sum += tempC;
                    }
                    for(int d = 0; d < 5; d++){
                        if(d == a || d == b || d == c){
                            continue;
                        }
                        sum += times[d];
                        int tempD = 0;
                        if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        }
                        for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        }
                        sum -= (times[d] + tempD);
                    }
                    sum -= (times[c] + tempC);
                }
                sum -= (times[b] + tempB);
            } int b = 0; int b = 0; b 0 b < 5 b 5 b++ b++ b {
                if(b == a){
                    continue;
                }
                sum += times[b];
                int tempB = 0;
                if(sum % 10 != 0){
                    tempB = 10 - sum % 10;
                    sum += tempB;
                }
                for(int c = 0; c < 5; c++){
                    if(c == a || c == b){
                        continue;
                    }
                    sum += times[c];
                    int tempC = 0;
                    if(sum % 10 != 0){
                        tempC = 10 - sum % 10;
                        sum += tempC;
                    }
                    for(int d = 0; d < 5; d++){
                        if(d == a || d == b || d == c){
                            continue;
                        }
                        sum += times[d];
                        int tempD = 0;
                        if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        }
                        for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        }
                        sum -= (times[d] + tempD);
                    }
                    sum -= (times[c] + tempC);
                }
                sum -= (times[b] + tempB);
            } {
                if(b == a){
                    continue;
                }
                sum += times[b];
                int tempB = 0;
                if(sum % 10 != 0){
                    tempB = 10 - sum % 10;
                    sum += tempB;
                }
                for(int c = 0; c < 5; c++){
                    if(c == a || c == b){
                        continue;
                    }
                    sum += times[c];
                    int tempC = 0;
                    if(sum % 10 != 0){
                        tempC = 10 - sum % 10;
                        sum += tempC;
                    }
                    for(int d = 0; d < 5; d++){
                        if(d == a || d == b || d == c){
                            continue;
                        }
                        sum += times[d];
                        int tempD = 0;
                        if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        }
                        for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        }
                        sum -= (times[d] + tempD);
                    }
                    sum -= (times[c] + tempC);
                }
                sum -= (times[b] + tempB);
            } if(b == a){
                    continue;
                } b == a b a {
                    continue;
                } continue; sum += times[b] sum times[b] times b int tempB = 0; tempB 0 if(sum % 10 != 0){
                    tempB = 10 - sum % 10;
                    sum += tempB;
                } sum % 10 != 0 sum % 10 sum 10 0 {
                    tempB = 10 - sum % 10;
                    sum += tempB;
                } tempB = 10 - sum % 10 tempB 10 - sum % 10 10 sum % 10 sum 10 sum += tempB sum tempB for(int c = 0; c < 5; c++){
                    if(c == a || c == b){
                        continue;
                    }
                    sum += times[c];
                    int tempC = 0;
                    if(sum % 10 != 0){
                        tempC = 10 - sum % 10;
                        sum += tempC;
                    }
                    for(int d = 0; d < 5; d++){
                        if(d == a || d == b || d == c){
                            continue;
                        }
                        sum += times[d];
                        int tempD = 0;
                        if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        }
                        for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        }
                        sum -= (times[d] + tempD);
                    }
                    sum -= (times[c] + tempC);
                } int c = 0; int c = 0; c 0 c < 5 c 5 c++ c++ c {
                    if(c == a || c == b){
                        continue;
                    }
                    sum += times[c];
                    int tempC = 0;
                    if(sum % 10 != 0){
                        tempC = 10 - sum % 10;
                        sum += tempC;
                    }
                    for(int d = 0; d < 5; d++){
                        if(d == a || d == b || d == c){
                            continue;
                        }
                        sum += times[d];
                        int tempD = 0;
                        if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        }
                        for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        }
                        sum -= (times[d] + tempD);
                    }
                    sum -= (times[c] + tempC);
                } {
                    if(c == a || c == b){
                        continue;
                    }
                    sum += times[c];
                    int tempC = 0;
                    if(sum % 10 != 0){
                        tempC = 10 - sum % 10;
                        sum += tempC;
                    }
                    for(int d = 0; d < 5; d++){
                        if(d == a || d == b || d == c){
                            continue;
                        }
                        sum += times[d];
                        int tempD = 0;
                        if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        }
                        for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        }
                        sum -= (times[d] + tempD);
                    }
                    sum -= (times[c] + tempC);
                } if(c == a || c == b){
                        continue;
                    } c == a || c == b c == a c a c == b c b {
                        continue;
                    } continue; sum += times[c] sum times[c] times c int tempC = 0; tempC 0 if(sum % 10 != 0){
                        tempC = 10 - sum % 10;
                        sum += tempC;
                    } sum % 10 != 0 sum % 10 sum 10 0 {
                        tempC = 10 - sum % 10;
                        sum += tempC;
                    } tempC = 10 - sum % 10 tempC 10 - sum % 10 10 sum % 10 sum 10 sum += tempC sum tempC for(int d = 0; d < 5; d++){
                        if(d == a || d == b || d == c){
                            continue;
                        }
                        sum += times[d];
                        int tempD = 0;
                        if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        }
                        for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        }
                        sum -= (times[d] + tempD);
                    } int d = 0; int d = 0; d 0 d < 5 d 5 d++ d++ d {
                        if(d == a || d == b || d == c){
                            continue;
                        }
                        sum += times[d];
                        int tempD = 0;
                        if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        }
                        for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        }
                        sum -= (times[d] + tempD);
                    } {
                        if(d == a || d == b || d == c){
                            continue;
                        }
                        sum += times[d];
                        int tempD = 0;
                        if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        }
                        for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        }
                        sum -= (times[d] + tempD);
                    } if(d == a || d == b || d == c){
                            continue;
                        } d == a || d == b || d == c d == a || d == b || d == c d == a d a d == b d b d == c d c {
                            continue;
                        } continue; sum += times[d] sum times[d] times d int tempD = 0; tempD 0 if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        } sum % 10 != 0 sum % 10 sum 10 0 {
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        } tempD = 10 - sum % 10 tempD 10 - sum % 10 10 sum % 10 sum 10 sum += tempD sum tempD for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        } int e = 0; int e = 0; e 0 e < 5 e 5 e++ e++ e {
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        } {
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        } if(e == a || e == b || e == c || e == d){
                                continue;
                            } e == a || e == b || e == c || e == d e == c e == a || e == b || e == c || e == d e == a e a e == b e b e == c e c e == d e d {
                                continue;
                            } continue; sum += times[e] sum times[e] times e if(sum < min){
                                min = sum;
                            } sum < min sum min {
                                min = sum;
                            } min = sum min sum sum -= times[e] sum times[e] times e sum -= (times[d] + tempD) sum (times[d] + tempD) times[d] times d tempD sum -= (times[c] + tempC) sum (times[c] + tempC) times[c] times c tempC sum -= (times[b] + tempB) sum (times[b] + tempB) times[b] times b tempB System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int[] times = new int[5];
        for(int i = 0; i < 5; i++){
            times[i] = scan.nextInt();
        }

        // search
        int min = Integer.MAX_VALUE;
        for(int a = 0; a < 5; a++){
            int sum = times[a];
            if(sum % 10 != 0){
                sum +=10 - sum % 10;
            }
            for(int b = 0; b < 5; b++){
                if(b == a){
                    continue;
                }
                sum += times[b];
                int tempB = 0;
                if(sum % 10 != 0){
                    tempB = 10 - sum % 10;
                    sum += tempB;
                }
                for(int c = 0; c < 5; c++){
                    if(c == a || c == b){
                        continue;
                    }
                    sum += times[c];
                    int tempC = 0;
                    if(sum % 10 != 0){
                        tempC = 10 - sum % 10;
                        sum += tempC;
                    }
                    for(int d = 0; d < 5; d++){
                        if(d == a || d == b || d == c){
                            continue;
                        }
                        sum += times[d];
                        int tempD = 0;
                        if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        }
                        for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        }
                        sum -= (times[d] + tempD);
                    }
                    sum -= (times[c] + tempC);
                }
                sum -= (times[b] + tempB);
            }
        }


        // answer
        System.out.println(min);

    }
} public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int[] times = new int[5];
        for(int i = 0; i < 5; i++){
            times[i] = scan.nextInt();
        }

        // search
        int min = Integer.MAX_VALUE;
        for(int a = 0; a < 5; a++){
            int sum = times[a];
            if(sum % 10 != 0){
                sum +=10 - sum % 10;
            }
            for(int b = 0; b < 5; b++){
                if(b == a){
                    continue;
                }
                sum += times[b];
                int tempB = 0;
                if(sum % 10 != 0){
                    tempB = 10 - sum % 10;
                    sum += tempB;
                }
                for(int c = 0; c < 5; c++){
                    if(c == a || c == b){
                        continue;
                    }
                    sum += times[c];
                    int tempC = 0;
                    if(sum % 10 != 0){
                        tempC = 10 - sum % 10;
                        sum += tempC;
                    }
                    for(int d = 0; d < 5; d++){
                        if(d == a || d == b || d == c){
                            continue;
                        }
                        sum += times[d];
                        int tempD = 0;
                        if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        }
                        for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        }
                        sum -= (times[d] + tempD);
                    }
                    sum -= (times[c] + tempC);
                }
                sum -= (times[b] + tempB);
            }
        }


        // answer
        System.out.println(min);

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

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int[] times = new int[5];
        for(int i = 0; i < 5; i++){
            times[i] = scan.nextInt();
        }

        // search
        int min = Integer.MAX_VALUE;
        for(int a = 0; a < 5; a++){
            int sum = times[a];
            if(sum % 10 != 0){
                sum +=10 - sum % 10;
            }
            for(int b = 0; b < 5; b++){
                if(b == a){
                    continue;
                }
                sum += times[b];
                int tempB = 0;
                if(sum % 10 != 0){
                    tempB = 10 - sum % 10;
                    sum += tempB;
                }
                for(int c = 0; c < 5; c++){
                    if(c == a || c == b){
                        continue;
                    }
                    sum += times[c];
                    int tempC = 0;
                    if(sum % 10 != 0){
                        tempC = 10 - sum % 10;
                        sum += tempC;
                    }
                    for(int d = 0; d < 5; d++){
                        if(d == a || d == b || d == c){
                            continue;
                        }
                        sum += times[d];
                        int tempD = 0;
                        if(sum % 10 != 0){
                            tempD = 10 - sum % 10;
                            sum += tempD;
                        }
                        for(int e = 0; e < 5; e++){
                            if(e == a || e == b || e == c || e == d){
                                continue;
                            }
                            sum += times[e];
                            if(sum < min){
                                min = sum;
                            }
                            sum -= times[e];
                        }
                        sum -= (times[d] + tempD);
                    }
                    sum -= (times[c] + tempC);
                }
                sum -= (times[b] + tempB);
            }
        }


        // answer
        System.out.println(min);

    }
}