I'm interested in the following question: find the number of partitions of an integer (for example, 1000) into 4 parts not exceeding given bound (for example, 511). How to approach this? If there was no restrictions for parts, the answer would be $C_{1003}^3$, but I don't know how to take into account those restrictions. Any suggestions?
Edit: parts don't have to be distinct.