Sir....I tried the below code.. #include #include using namespace std; int main() { long long int n,count=0; int length,i; string sub_str; getline(cin,sub_str); cin>>n; length = sub_str.length(); if(length==1) { if(sub_str[i]=='a') { count=n; } else { count=0; } } // finding number of a's in substring else if(length>1) { for(i=0;i