import std.stdio, std.range, std.conv, std.string;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;

int calc(int time, int[] n)
{
    if(n.length==0)
    {
        return time;
    }
    while(time%10!=0)
    {
        time++;
    }
    int res =int.max;
    for(int i =0;i < n.length;i++)
    {
        int[] cn = n.dup;
        auto e = cn[i];
        cn = cn.remove(i);
        auto m = calc(time + e, cn);
        res = min(res, m);
    }
    return res;
}
void main() {
    int[] list;
    for (int i = 0; i < 5; ++i) {
        list~=readln().strip.to!int;
    }
    writeln(calc(0, list));
}
