using System;
using System.Collections.Generic;

public class Answer {
    private static void Main(string[] args) {
        var numberOfLines = 5;
        var inputs = new List<string>();
        
        for (int lineIndex = 0; lineIndex < numberOfLines; lineIndex++) {
            inputs.Add(Console.ReadLine().Trim());
        }
        
        Console.WriteLine(GetAnswer(inputs));
    }
  
    private static string GetAnswer(List<string> inputs) {
        var menus = new List<(int sortNumber, int minutes)>();

        foreach (var input in inputs) {
            var minutes = int.Parse(input);
            var sortNumber = CalculateSortNumber(minutes);
            menus.Add((sortNumber, minutes));
        }

        menus.Sort((a, b) => (b.sortNumber - a.sortNumber));

        var totalMinutes = 0;
        for (int index = 0; index < menus.Count - 1; index++) {
            totalMinutes += CalculateWaitingTime(menus[index].minutes);
        }
        totalMinutes += menus[menus.Count - 1].minutes;

        return totalMinutes.ToString();
    }

    private static int CalculateSortNumber(int minutes) => minutes % 10 == 0 ? 10 : minutes % 10;
    private static int CalculateWaitingTime(int minutes) => minutes % 10 == 0 ? minutes : minutes + 10 - (minutes % 10);
}