#include
using namespace std;
#include
enum itsaWord { NO, YES };
int main(){
itsaWord isWord = NO;
char ch = 'a';
int wordcount = 0;
cout << "Enter a phrase:\n";
do {
ch = getche();
if(ch==' ' || ch=='\r'){
if( isWord == YES ){
wordcount++;
isWord = NO;
}
}else if( isWord == NO ){
isWord = YES;
}
} while( ch != '\r' );
cout << wordcount;
return 0;
}