import std.stdio;
import std.range;
import std.array;
import std.algorithm;
import std.string;
import std.conv;
import std.typecons;
import std.math;
import std.numeric;

void main() {
    int[] input;
    foreach (i; 0 .. 5) {
        input ~= readln().chomp().to!int;
    }

    solve(input).writeln();
}

int solve(int[] foods) {
    foods.sort!((f1, f2) {
        auto f1_1 = f1 % 10;
        auto f2_1 = f2 % 10;
        return (10 - f1_1) % 10 < (10 - f2_1) % 10;
    });
    int time = 0;
    foreach (food; foods) {
        if (time % 10 != 0) {
            time = 10 * (time / 10 + 1);
        }
        time += food;
    }
    return time;
}

unittest {
    assert(solve([29, 20, 7, 35, 120]) == 215, solve([29, 20, 7, 35, 120]).to!string);
    assert(solve([101, 86, 119, 108, 57]) == 481, solve([101, 86, 119, 108, 57]).to!string);
    assert(solve([123, 123, 123, 123, 123]) == 643, solve([123, 123, 123, 123, 123]).to!string);
}
