Function to count total no . of ways
static int countWays ( string str ) { int [ ] freq = new int [ 200 ] ; for ( int i = 0 ; i < 200 ; i ++ ) freq [ i ] = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) freq [ str [ i ] - ' a ' ] ++ ;