How to extract int from data?

Hi,

I need to extract integers from the following input file and put them into different input variables. Anyone can share some tips how to do it?

The input file is something like that:

Rec1-0($51) Rec2-0($25) 821

Rec1-1($45) Rec2-1($85) 121

Rec1-2($4) Rec2-2($5) 1421

Meaning to say, for the 1st line, I need to input 0, 51, 0, 25 and 821 into separate int variables. For 2nd line, need to input 1, 45, 1, 85 and 121 into another set of int variables, and so on...

Would appreciate you kind help...Thanks in advance!