this to me seems like a permutatiion combinations post rather than a quadratic..
anyways here is wat i thinnk we can proceed like:
3 cases:
we have 5 digits
case1: only 2 is present and not 5
case2:only 5 is present and not 2
case3: both 2 and 5 are present
now u can proceed i guess.. still if u ahve any problem please say