%{
  #include<stdio.h>
  int lc = 0, sc = 0, tc = 0, ch = 0, wc = 0;
%}
 
// Rules to identify if a character apart from alphabets
// occurs in a string
 
%%
[\n] {lc++; ch += yyleng;}
[ \t] {sc++; ch += yyleng;}
[^\t] {tc++; ch += yyleng;}
[^\t\n]+ {wc++; ch += yyleng;}
%%
  
// code section
int yywrap() {return 1;}
   
int main()
 { 
   printf("Enter the Sentence: ");
   yylex();
   printf("Number of Lines: %d\n", lc);
   printf("Number of Spaces: %d\n", sc);
   printf("Number of Tabs: %d\n", wc);
   
  return 0;
 }