Dynamic programming

I have a nxn matrix,which contains some numbers as values in the grid and some grid contains the block.I have to find the number of path from the source to destination which adds upto given sum k

input:
s 1 1
1 x 1
1 1 d

k = 3

output : 2

There are only two paths possible from source to destination for a given sum.

Implement using Dynamic programming either in c/c++

Use Dijkstra's algorithm - Wikipedia
Dont stop after finding the cheapest path, but go on until all paths of cost k are created. Count the ones ending at d.