(* O(n) *)
let rec fold_btw f a i n = if i >= n then a else fold_btw f (f a i) (i + 1) n
let fold_int f a n = fold_btw f a 0 n

(* O(n^2) *)
let solve r g b n =
  fold_int
    (fun acc_r r0 ->
      fold_int
        (fun acc_g g0 ->
          let rg = r0 * r + g0 * g in
          if rg > n then
            acc_g
          else if (n - rg) mod b = 0 then
            acc_g + 1
          else
            acc_g)
        acc_r
        (n + 1))
    0
    (n + 1)

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string

let _ =
  match read_ints () with
  | [r; g; b; n] -> solve r g b n |> string_of_int |> print_endline
  | _ -> ()