%{
int count = 0;  // Initialize the count of capital letters
%}

%%

[A-Z] {  // If the token is a capital letter
    printf("%s capital letter\n", yytext);
    count++;  // Increment the count
}

. {  // For any other character
    printf("%s not a capital letter\n", yytext);
}

\n { return 0; }  // When newline is encountered, return 0 to stop processing

%%

int yywrap() {
    return 1;  // Return 1 to indicate that input is finished
}

int main() {
    printf("Enter text: ");
    yylex();  // Start lexical analysis
    printf("\nNumber of Capital letters in the given input - %d\n", count);  // Output the result
    return 0;
}
