#!/usr/bin/ruby
# encoding: utf-8

a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i

ans = 650
ary = [a,b,c,d,e].permutation(5).to_a

(0..ary.size-1).each do |i|
  sum = 0
  (0..4).each do |j|
    if j == 4 then
      sum += ary[i][j]
    else
      sum += ary[i][j].ceil(-1)
    end
  end

  if ans >= sum then
    ans = sum
  end
end

puts ans
