#include <bits/stdc++.h>
int main() {
  int jh = 0;
  int tk = 0;
  int l = 0;
  int i = 0;
  int a[5];
  int tmp[5];
  int time = 0;
  int o[5];
  int max = 0;
  for (i = 0; i < 5; i++) {
    o[i] = 0;
    a[i] = 0;
  }
  for (i = 0; i < 5; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < 5; i++) {
    tmp[i] = 1000;
  }
  for (i = 0; i < 5; i++) {
    for (int k = 0;; k++) {
      if (a[i] % 10 == 0) {
        break;
      } else {
        tmp[i]--;
      }
    }
  }
  for (i = 0; i < 5; i++) {
    if (max > tmp[i]) {
      max = tmp[i];
      tk = i;
      o[jh] = i;
      jh++;
    }
  }
  for (i = 0; i < 5; i++) {
    if (max > tmp[i]) {
      max = tmp[i];
      tk = i;
      o[jh] = i;
      jh++;
    }
  }
  for (i = 0; i < 5; i++) {
    if (max > tmp[i]) {
      max = tmp[i];
      tk = i;
      o[jh] = i;
      jh++;
    }
  }
  for (i = 0; i < 5; i++) {
    if (max > tmp[i]) {
      max = tmp[i];
      tk = i;
      o[jh] = i;
      jh++;
    }
  }
  for (i = 0; i < 5; i++) {
    if (max > tmp[i]) {
      max = tmp[i];
      tk = i;
      o[jh] = i;
      jh++;
    }
  }
  tk = 0;
  for (int tk = 0; tk < 4; tk++) {
    time += o[tk];
    for (int i = 0;; i++) {
      if (time % 10 == 0) {
        break;
      } else {
        time += 1;
      }
    }
  }
  for (int i = 0;; i++) {
    if (time % 10 == 0) {
      break;
    } else {
      time += 1;
    }
  }
  time += o[4];
  printf("%d", time);
  return 0;
}
