The AS5400 can handle up to 16E1 so can handle 16x31=496 TDM to IP calls (or vice versa).
If you want use the AS5400 as an IP2IP gateway to handle SIP to SIP calls, the maximum concurrent sessions are 600.
I don't have direct experience with AS5850 but the behaviour should be the same.
If I correctly remember you can handle 63E1 in 4DS3 so 63x2x31=3906 calls.
In IP2IP mode the calls should be more.
Consider that the Cisco AS5850 has a total of 4 such buses, each bus supports 2048 DS0s card, so the total DS0 capacity is 8192.
Regards.