program diverta2019b
  implicit none
  integer r, g, b, n, i
  integer, allocatable :: a(:)

  read *, r, g, b, n
  allocate(a(0:n))
  a = 0
  a(0) = 1

  do i = r, n
     a(i) = a(i) + a(i - r)
  end do

  do i = g, n
     a(i) = a(i) + a(i - g)
  end do

  do i = b, n
     a(i) = a(i) + a(i - b)
  end do

  print *, a(n)
end program diverta2019b
