You need to loop through the string, and each time round the loop, find the character at the position indicated by your loop counter, and if that character is an 'a', increment another counter.