Magic number = 1237

The Democrats allocate all their delegates proportionally. On top of those delegates, there are super-delegates to be won over. In any case, barring some very strange turn of events, Clinton is coasting to the nomination.

The Republican delegate allocation system is highly diverse since they leave it up to the state parties to set the rules of how to divide it up.

Broadly, there are four types:
Winner-take-all (Florida and Ohio were recent examples; Arizona coming up is another; there are few more)
Winner-take-all by Congressional districts (Illinois and Missouri were recent examples; California will be the biggest example at the very end)
Proportional by Congressional districts (many)
Proportional by state-wide (many)

The basic outline above can be modified in a myriad of ways. For example, there can be thresholds that must be crossed before delegates can be awarded to eliminate low vote getting candidates from picking up any delegates. Some states that allocate by Congressional districts may also offer a batch of delegates based on state-wide results. It can get quite complicated!

The net effect of these modifications to the basic format is to magnify the delegate collection of candidates who perform well throughout a state. For example, in Alabama, Trump got 36 out of 50 delegates (72%) because he won throughout the state even with only 43% of the vote overall.

And there in lies the danger to the #NotTrump movement: if Trump consistently pulls ~ 40% throughout a state and Kasich and Cruz split the remaining 60%, Trump wins far more than 40% of the delegates in those states. Thus, by dividing the #NotTrump vote between two candidates, Trump could get a "back-door" winner-take-most of the delegates in many states.