Problem:
Score: 200 points

Problem Statement

The restaurant AtCoder serves the following five dishes:

ABC Don (rice bowl): takes A minutes to serve.

ARC Curry: takes B minutes to serve.

AGC Pasta: takes C minutes to serve.

APC Ramen: takes D minutes to serve.

ATC Hanbagu (hamburger patty): takes E minutes to serve.

Here, the time to serve a dish is the time between when an order is placed and when the dish is delivered.

This restaurant has the following rules on orders:

An order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).

Only one dish can be ordered at a time.

No new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.

E869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.

Here, he can order the dishes in any order he likes, and he can place an order already at time 0.

Constraints

A, B, C, D and E are integers between 1 and 123 (inclusive).

Input

Input is given from Standard Input in the following format:

A
B
C
D
E

Output

Print the earliest possible time for the last dish to be delivered, as an integer.

Sample Input 1

29
20
7
35
120

Sample Output 1

215

If we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:

Order ABC Don at time 0, which will be delivered at time 29.

Order ARC Curry at time 30, which will be delivered at time 50.

Order AGC Pasta at time 50, which will be delivered at time 57.

Order ATC Hanbagu at time 60, which will be delivered at time 180.

Order APC Ramen at time 180, which will be delivered at time 215.

There is no way to order the dishes in which the last dish will be delivered earlier than this.

Sample Input 2

101
86
119
108
57

Sample Output 2

481

If we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:

Order AGC Pasta at time 0, which will be delivered at time 119.

Order ARC Curry at time 120, which will be delivered at time 206.

Order ATC Hanbagu at time 210, which will be delivered at time 267.

Order APC Ramen at time 270, which will be delivered at time 378.

Order ABC Don at time 380, which will be delivered at time 481.

There is no way to order the dishes in which the last dish will be delivered earlier than this.

Sample Input 3

123
123
123
123
123

Sample Output 3

643

This is the largest valid case.

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

// だーれだ？
//qqqqqqHHMqqqqqHf!(:;jHmmkf``(:;jkqqqqqqqqqmMH#HMqqK_````````````````(kqqqqqqHMMM
//qqqqqqHHmqqqqH=` :;;jkqH=?~..;;jqqqqqqqqqmM#HM#MHH!```` ```````..-``dqWbWkRqHMMM
//qqqqqqMHmqqqK!``.;;;dqH: ```.?TUqqHmqqqqmHHHM4Mqkt..```` ..JgHHW@P`.HHkqHHHqM#NN
//qqqqqmHMmqHTYWHgHmmgHR...``` :;Jkq9qqqqqgMH#1dHk$...-gW@HY"=!``dH! dHNmqqqqmM###
//qqqqqqgMmH[````` ?dHMMMHHHHHJ<;JkK>XqqqmMH#<+Hb%.WYYTHppf-````.gt`.HHMmmqqqmM###
//qqkqqqm@H?S,```` Jpbbpp:```` :!dK<;JkqqMMY(;dW^````.ppbpf!```.Y<`.HHHMgmqqqmH###
//qqqqqqqqD`` ````(ppbppW````` ~.f`:;jkqM#^.;jf!````.Wppbpf````````(HH#HmmqqmH#NN#
//qqqqqqqkP``````.fpbpbpf``` ` `.``~:;WHY``(+=``````Jppbpf\```` ``.MH#HHgqqqmHNNNN
//qqqqqqqk]```` `,fpbbpf>```` `` ``_:<? ``.?!``` `` Wpppp%``` ``` dHH##HmmqqmH####
//qqqqqqqk]``````,fpbppt``` `` `` `_~````` `` `` ```WppW=``` ````.HHHHMHmmqqmM####
//qqqqqqqk$`` ````4ppfY```` `` `` `- `` `` `` ``` ``(T=`````` ``.MH##HMMmmqqmM##HH
//qqqqqqHqP``` ````?7!```` `` `` ``` `` ` ` ``  ````````` ` ````.MHH#HgMmqmqmHHHHH
//qqqkqqmkR```` `        `` ` `` ` ` ` ``` ` ``` `   ......_. ```dH#HHgMqqgqqmH#HH
//NqqqqqHqR```  _ ........_` `` ``` ``` ````` ``` ............```,HHHHmqqqHqqmMH##
//MmqqqqHqR```  _........_ `` `` ``` `` `  `` ` ` `  `__     ` ``,HHHMmmqqMHmmMHH#
//HMqqqqXkH `````````````` ` `` `  `` `` `` `` `` ```` ````` ````.HHHMmMHm@HHqmMHH
//HHHmqqfHk;``` `  ` `` ` ` `` ``` ` ` ``` `` `` `` ````  `..```.HHHHMMHMg@HHHHHMH
//HHMmmqMHkP<.`` ``` ` ` ``` `` ``` ``` ` `` `` `` `  ````  ```.MH##HM#HMg@@@@H@HH
//##HNmqR`jW<<_ ``` ````` `` ` ` ``` `` `` `` `` ````  ````` .dHH##H#HHHMHH@@H@@@@
//HH##NqH..X2:<<-.`` ` `` ``` ``` ` `` `` `` ` `` ` ``` ` .gMHHH#H#HHH#HM@@H@@H@@H
//-WHHHNH[ =v._:::<-. ` `` ` ``  ```````.`` `````````     .MHH###H#MHHHHH@H@H@@HH@
//` 7MHHMH.l==.  ~:::::<_-.. ````` ``````` ``  ...uX;     `,MHHHH#M@@MM@@@@@@H@@@@
//  . TMHHbZl=1.   _~::::::(<::<:<___-___:<<:::::jX3=. ` ` `,MMHM@@@@Mg@@@@@@@@@H@
//
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb push_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed;
// cout << setprecision(10) << val;

signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  vii a(5, 0);
  cin >> a;
  sort(ALL(a));
  int ans = INF;
  do {
    int sum = 0;
    rep(i, 0, 4) {
      sum += (a[i] % 10 ? (a[i]/10 + 1) * 10 : a[i]);
    }
    sum += a[4];
    chmin(ans, sum);
  } while (next_permutation(ALL(a)));
  cout << ans << endl;
  return 0;
}