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

int main() {
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  int f=min(min(min((a-1)%10,(b-1)%10),min((c-1)%10,(d-1)%10)),(e-1)%10); 
  int time=0;
  time+=(10-a%10)%10+a+(10-b%10)%10+b+(10-c%10)%10+c+(10-d%10)%10+d+(10-e%10)%10+e;
  cout<<time-(10-(f+1))<<endl;
}