#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <queue>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <set>

using namespace std;

void solve();

int main() {
	solve();
	return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////

int time[5];

void solve() {
	for (int k = 0; k < 5; k++)cin >> time[k];
	int arr[5];
	for (int k = 0; k < 5; k++)arr[k] = k;
	int m = 130*5;
	do {
		int t = 0;
		for (int k = 0; k < 5; k++) {
			if (t % 10 != 0)t = (int)(10 * ceil((double)t/10));
			t += time[arr[k]];
		}
		m = min(m,t);
	} while (next_permutation(arr,arr+5));
	cout << m << endl;
	return;
}