using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            
            var line = new List<int>();

            for (int i = 0; i < 5; i++)
            {
                line.Add(int.Parse(Console.ReadLine()));
            }

            var minlist = line.Select(i => i % 10).ToList();
            if (minlist.All(i => i == 0)) {
                Console.WriteLine(0);
                return;
            } 
            minlist.RemoveAll(i => i == 0);
            int min = minlist.Min();

            var target = line.Where(i => i % 10 == min).ToList();
            line.Remove(target[0]);
            line.Add(target[0]);

            int time = 0;

            for (int i = 0; i < 5; i++)
            {
                time += line[i];

                if (i == 4) break;
                else if (line[i] % 10 !=0)
                {
                    time += (10 - (line[i] % 10));
                }
            }

            Console.WriteLine(time);

            
            
           

        }
    }
}
