using System;

class Program
{
  static void Main(string[] args)
  {
    int[] cuisine = new int[5];
    int[] A = new int[5];
    for(int i = 0; i < 4; i++)
    {
      cuisine[i] = int.Parse(Console.ReadLine());
      A[i] = cuisine[i] % 10;
    }
    Array.Sort(A);
    for(int j = 0; j < 4; j++)
    {
      for(int k = 0; k < 4; k++)
      {
        if(A[j] == cuisine[k] % 10) A[j] = cuisine[k];
      }
    }
    int[] B = new int[4];
    for(int l = 0; l < 3; l++)
    {
      B[l] = 10 - A[l];
    }
    int M = cuisine[0]cuisine[1] + cuisine[2] + cuisine[3] + cuisine[4];
    int N = B[0] + B[1] + B[2] + B[3];
    Console.WriteLine(N + M);
  }
}