function Main(input) {
  input = input.split("\n");
  var a = ~~input[0];
  var b = ~~input[1];
  var c = ~~input[2];
  var d = ~~input[3];
  var e = ~~input[4];

  var AtCoder = function(a,b,c,d,e){
    this.menu = {"Don":a,"Curry":b,"Pasta":c,"Ramen":d,"Hamburg":e};
    this.max = a+b+c+d+e+50;
  };

  AtCoder.prototype = {
    procedure: function(){
      var max_time=10000000;
      for(item1 in this.menu){
        var time1 = 0;
        time1 = time1+(this.menu[item1]+(10-this.menu[item1]%10)%10);
        for(item2 in this.menu){
          if(item1 == item2) continue;
          var time2 = time1;
          time2 = time2+(this.menu[item2]+(10-this.menu[item2]%10)%10);
          for(item3 in this.menu){
            if(item1 == item3 || item2 == item3) continue;
            var time3 = time2;
            time3 = time3+(this.menu[item3]+(10-this.menu[item3]%10)%10);
            for(item4 in this.menu){
              if(item1 == item4 || item2 == item4 || item3 == item4) continue;
              var time4 = time3;
              time4 = time4+(this.menu[item4]+(10-this.menu[item4]%10)%10);
              for(item5 in this.menu){
                if(item1 == item5 || item2 == item5 || item3 == item5 || item4 == item5) continue;
                var time5 = time4;
                time5 = time5+this.menu[item5];
                if(max_time > time5) max_time=time5;
              }
            }
          }
        }
      }
      return max_time;
    }
  }
  var atcoder = new AtCoder(a,b,c,d,e);
  console.log(atcoder.procedure());
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
