program main
   implicit none
   integer:: r(3),n,i,j,k,counter=0,a(3)
   read(*,*)r,n
   a(1)=maxval(r)
   a(3)=minval(r)
   r(maxloc(r))=0
   a(2)=maxval(r)

   do i=0,n
      
      do j=0,n
         
         do k=0,n
            if(a(1)*k+a(2)*j+a(3)*i==n)then
               counter=counter+1
               exit
            endif
            if(a(1)*k+a(2)*j+a(3)*i>n)then
               exit
            endif
         enddo
         if(a(2)*j+a(3)*i>n)exit
      enddo
      if(a(3)*i>n)exit
   enddo
   write(*,*)counter
end program main
