#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> a;
  int s[4];
  int m = 0;
  int min = 0;
  int i;
  int j;
  int t = 0;
  for (i = 0; i < 5; i++) {
    cin >> j;
    a.push_back(j);
  }
  for (i = 0; i < 5; i++) {
    t = t + a[i];
    if (t % 10 == 0) {
    } else if (t % 10 != 0) {
      for (;;) {
        t = t + 1;
        m = m + 1;
        if (t % 10 == 0) {
          if (m > min) {
            min = m;
            m = 0;
          }
          break;
        }
      }
    }
  }
  cout << t - min << endl;
}
