What does it mean for a function to be constant in discrete math terms?

For instance, if I have two sets of numbers

D = {2, 3, 5, 7, 11, 13, 17, 23, 29, 31}

R = {2, 4, 6, 8, 10}

f: D -> R has 5^10 functions

f: R -> D has 10^5 functions

f: D -> D has 10^10 functions

(Are these all correct?)

But how many constant functions exist:

f: D -> R

f: R -> D

And how many functions f: D -> R exist such that f(5) = f(11) = 8?