Check for a subsequence of size 2
if ( ! flag ) { for ( int j = 0 ; j < S . length ( ) - 1 ; j ++ ) { for ( int j1 = j + 1 ; j1 < S . length ( ) ; j1 ++ ) { dummy = S [ j ] + S [ j1 ] ; if ( dummy != "23" && dummy != "37" && dummy != "53" && dummy != "73" ) { cout << 2 ; } if ( flag = true ) break ; } if ( flag = true ) break ; } }