Code golf: Distributing the balls (I)
JavaScript (90 93)

function f(a,b){n=m=r=1;for(i=b;i&gt;0;n*=-1){r+=n*m*Math.pow(i,a);m=m*i/(b-i--+1)}return--r}


http://jsfiddle.net/RDGUn/2/

Obviously, any math-based language such as APL will beat me because of syntax verbosity and lack of built-in mathematical constructs :)

Edit Also, I don't have any input-related functionality  except parameters passed into the function, not sure how to use standard input with JavaScript...

Edit: Move i-- into m=m* expression; move n*=-1 into for; start r=1 to  combine assignments and remove extraneous one on return. (save 3 chars)