import numpy as np

import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

sys.setrecursionlimit(10**8)

INF = float('inf')

MOD = 10**9+7





def main():

  A = int(eval(input()))

  B = int(eval(input()))

  C = int(eval(input()))

  D = int(eval(input()))

  E = int(eval(input()))

  

  a = (10 - A) % 10

  b = (10 - B) % 10

  c = (10 - C) % 10

  d = (10 - D) % 10

  e = (10 - E) % 10

 

  print((A+B+C+D+E+a+b+c+d+e-max([a,b,c,d,e])))

  

  

  

if __name__ == '__main__':

  main()
def main():

  A = int(eval(input()))

  B = int(eval(input()))

  C = int(eval(input()))

  D = int(eval(input()))

  E = int(eval(input()))

  

  a = (10 - A) % 10

  b = (10 - B) % 10

  c = (10 - C) % 10

  d = (10 - D) % 10

  e = (10 - E) % 10

 

  print((A+B+C+D+E+a+b+c+d+e-max([a,b,c,d,e])))

  

  

  

if __name__ == '__main__':

  main()
import numpy as np
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float("inf")
MOD = 10**9 + 7


def main():
    A = int(eval(input()))
    B = int(eval(input()))
    C = int(eval(input()))
    D = int(eval(input()))
    E = int(eval(input()))
    a = (10 - A) % 10
    b = (10 - B) % 10
    c = (10 - C) % 10
    d = (10 - D) % 10
    e = (10 - E) % 10
    print((A + B + C + D + E + a + b + c + d + e - max([a, b, c, d, e])))


if __name__ == "__main__":
    main()

def main():
    A = int(eval(input()))
    B = int(eval(input()))
    C = int(eval(input()))
    D = int(eval(input()))
    E = int(eval(input()))
    a = (10 - A) % 10
    b = (10 - B) % 10
    c = (10 - C) % 10
    d = (10 - D) % 10
    e = (10 - E) % 10
    print((A + B + C + D + E + a + b + c + d + e - max([a, b, c, d, e])))


if __name__ == "__main__":
    main()

-import numpy as np -import sys - -read = sys.stdin.buffer.read -readline = sys.stdin.buffer.readline -readlines = sys.stdin.buffer.readlines -sys.setrecursionlimit(10**8) -INF = float("inf") -MOD = 10**9 + 7 - -