import sys
def bouquets(narcissus_price, tulip_price, rose_price, summ):
prices = sorted([narcissus_price, tulip_price, rose_price], reverse=True)
pr_b = prices[0]
pr_s = prices[1]
pr_m = prices[2]
rb = int(summ / pr_b) + 1
rs = int(summ / pr_s) + 1
rm = int(summ / pr_m) + 1
counter = 0
for b in range(rb):
sb = b * pr_b
for s in range(rs):
ss = s * pr_s
if ss + sb > summ: break
for m in range(rm):
sm = m * pr_m
pr = sb + ss + sm
if pr > summ: break
if pr <= summ and (b + s + m) % 2 != 0:
counter += 1
return counter
print bouquets(200,300,400,100000) # 3524556
aW1wb3J0IHN5cwoKZGVmIGJvdXF1ZXRzKG5hcmNpc3N1c19wcmljZSwgdHVsaXBfcHJpY2UsIHJvc2VfcHJpY2UsIHN1bW0pOgogICAgcHJpY2VzID0gc29ydGVkKFtuYXJjaXNzdXNfcHJpY2UsIHR1bGlwX3ByaWNlLCByb3NlX3ByaWNlXSwgcmV2ZXJzZT1UcnVlKQogICAgcHJfYiA9IHByaWNlc1swXQogICAgcHJfcyA9IHByaWNlc1sxXQogICAgcHJfbSA9IHByaWNlc1syXSAgICAKICAgIHJiID0gaW50KHN1bW0gLyBwcl9iKSArIDEKICAgIHJzID0gaW50KHN1bW0gLyBwcl9zKSArIDEKICAgIHJtID0gaW50KHN1bW0gLyBwcl9tKSArIDEKICAgIGNvdW50ZXIgPSAwCiAgICBmb3IgYiBpbiByYW5nZShyYik6CiAgICAgICAgc2IgPSBiICogcHJfYgogICAgICAgIGZvciBzIGluIHJhbmdlKHJzKToKICAgICAgICAgICAgc3MgPSBzICogcHJfcwogICAgICAgICAgICBpZiBzcyArIHNiID4gc3VtbTogYnJlYWsKICAgICAgICAgICAgZm9yIG0gaW4gcmFuZ2Uocm0pOgogICAgICAgICAgICAgICAgc20gPSBtICogcHJfbQogICAgICAgICAgICAgICAgcHIgPSBzYiArIHNzICsgc20KICAgICAgICAgICAgICAgIGlmIHByID4gc3VtbTogYnJlYWsKICAgICAgICAgICAgICAgIGlmIHByIDw9IHN1bW0gYW5kIChiICsgIHMgKyBtKSAlIDIgIT0gMDoKICAgICAgICAgICAgICAgICAgICBjb3VudGVyICs9IDEgICAgCiAgICByZXR1cm4gY291bnRlcgoKcHJpbnQgYm91cXVldHMoMjAwLDMwMCw0MDAsMTAwMDAwKSAjIDM1MjQ1NTY=