human
Count of sub | Function to return the count of required sub - strings.
Number of sub - strings from position of current x to the end of str.
To store the number of characters before x.
Driver code"
Solution in Python:
assistant
#Here is code to count of sub and the other steps required.
 def countSubStr ( str , n , x ) :
	res = 0 ; count = 0 ;
	for i in range ( n ) :
		if ( str [ i ] == x ) :
			res += ( ( count + 1 ) * ( n - i ) ) ;
			count = 0 ;
		else :
			count += 1 ;
	return res ;
str = " abcabc " ;
n = len ( str ) ;
x = ' c ' ;
print ( countSubStr ( str , n , x ) ) ;