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

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  vector<int> A(5);
  A = {a, b, c, d, e};
  vector<int> index(5);
  index = {0, 1, 2, 3, 4};
  int besttime = 0;
  do { for(int i = 0; i < 5; i++) {
    int nowtime = 0;
    while (nowtime % 10 != 0) nowtime++;
    nowtime += A.at(index.at(i));
    besttime = min(besttime, nowtime);
    {
  }while (next_permutation(index.begin(), index.end()));
  cout << besttime << endl;
  }