Function that returns true if the num contains a and b digits only
static bool check ( long num , long a , long b ) { while ( num > 0 ) { long rem = num % 10 ; num /= 10 ; if ( rem != a && rem != b ) return false ; } return true ; }