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

int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int n;
	vector<int> time = {a, b, c, d, e};
	vector<int> index = {0, 1, 2, 3, 4};
	int bestTime = 1e9;
	do {
		int nowTime = 0;
		for (int i = 0; i < n; i++) {
			while (nowTime % 10 != 0) nowTime++;
			nowTime += time[index[i]];
		}
		bestTime = min(bestTime, nowTime);q
	} while (next_permutation(index.begin(), index.end()));

	return 0;
}