I have following plan for the free item distribution

purchase of 3 items under a same  brands will get 1 gift item free
purchase of 5 items under a same  brands will get 2  gift item free
purchase of 10 items under a same  brands will get 4  gift item free


now if some buyer buys 13 items then he wil get free ites
4 for first 10
1 for the remaining 3

tell me how to make a drl with this thing'