#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<int> a(5);

int main() {
    ios::sync_with_stdio(false);
    for (int i = 0; i < 5; i++)
        cin >> a[i];
    vector<int> p = {0,1,2,3,4};
    int fans = 987654321;
    do {
        int ans = 0;
        for (int i = 0; i < 5; i++) {

            while (ans % 10 != 0)
                ans++;

            ans += a[p[i]];
        }
        fans = min(f, ans);

    }while (next_permutation(p.begin(), p.end()));

    cout << fans << endl;


    return 0;
}
