program tetromino_tiling
  implicit none
  integer, parameter :: i = 1, o = 2, t = 3, j = 4, l = 5, s = 6, z = 7
  integer(8) :: a(7), k0, k1
  a = 0_8
  read(*,*) a(i:z)
  k0 = 2_8*(a(i)/2_8+a(j)/2_8+a(l)/2_8)+a(o)
  k1 = 3_8+2_8*((a(i)-1_8)/2_8+(a(j)-1_8)/2_8+(a(l)-1_8)/2_8)+a(o)
  if (a(i).eq.0_8.or.a(j).eq.0_8.or.a(l).eq.0_8) k1 = 0_8
  write(*,'(i0)') max(k0,k1)
  stop
end program tetromino_tiling