Let n be the number of nickels
Let d be the number of dimes
There are 31 coins in your pocket:

You have in total $2.65:

Use the two equations above a system of linear equations to solve the variables n and d:

1. Solve n in the fist equation:

2. Use the value of n=31-d in the second equaiton:

3. Solve d:

4. Use the value of d=22 to solve n:

Then, you have 9 nickels and 22 dimes in your pocket