There are people who cycle between benefit and prison. It's highly likely that there's significant overlap between the numbers below.
I've just got the data for 2011.
Benefit ceased for reason of 'in prison' numbered 4,304
Benefit granted for reason of 'released from prison' numbered 3,815
The numbers in 2009 were respectively 4,192 and 3,496
2008 - 3,050 and 3,144
2007 - 2,860 and 3,171
2001 - 3,563 and 4,467
There's a trend there. Interesting. Under a Labour government more people were granted a benefit on release than had a benefit stopped on incarceration. Under a National government, that has reversed.
What can be said for certain is that more people on benefits are going to prison. Of course, it's still only a tiny fraction of the beneficiary population.
But it's quite a large fraction of the prison population.