Initialize dp
for ( int i = 0 ; i < dp . length ; i ++ ) for ( int j = 0 ; j < dp [ i ] . length ; j ++ ) for ( int k = 0 ; k < dp [ i ] [ j ] . length ; k ++ ) for ( int k1 = 0 ; k1 < dp [ i ] [ j ] [ k ] . length ; k1 ++ ) dp [ i ] [ j ] [ k ] [ k1 ] = - 1 ; return count ( 0 , 0 , 0 , 0 , num ) ; }