#include <iostream>
#include <string>
#include <sstream>
#include <map>
using namespace std;
int main() {
    string str;
    getline(cin,str);
    map<string,int> mp;
    stringstream s(str);
    string word;
    int count=0;
    while(s>>word){
        // cout<<word<<"\n";
        mp[word]++;
        count++;
    }
    cout<<"No. of words: "<<count<<"\n";
    
    for(auto it:mp){
        cout<<it.first<<" "<<it.second<<"\n";
    }
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: