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

int main() {
  int x = 0;
  int A, B, C, D, E;
  int a, b, c, d, e;
  cin >> A >> B >> C >> D >> E;
  a = A;
  b = B;
  c = C;
  d = D;
  e = E;
  A %= 10;
  B %= 10;
  C %= 10;
  D %= 10;
  E %= 10;
  
  if(A<=B&&A<=C&&A<=D&&A<=E) 
    x += b+(10-B)+c+(10-C)+d+(10-D)+e+(10-E)+a;
  else if(B<=A&&B<=C&&B<=D&&B<=E)
    x += a+(10-A)+c+(10-C)+d+(10-D)+e+(10-E)+b;
  else if(C<=A&&C<=B&&C<=D&&C<=E)
    x += a+(10-A)+b+(10-B)+d+(10-D)+e+(10-E)+c;
  else if(D<=A&&D<=B&&D<=C&&D<=E)
    x += a+(10-A)+b+(10-B)+c+(10-C)+e+(10-E)+d;
  else if(E<=A&&E<=B&&E<=C&&E<=D)
    x += a+(10-A)+b+(10-B)+c+(10-C)+d+(10-D)+e;
  
  if {
    if(A==0)
      x -= 10;
    if(B==0)
      x -= 10;
    if(C==0)
      x -= 10;
    if(D==0)
      x -= 10;
    if(E==0)
      x -= 10;
  }
  
  cout << x << endl;
}