#include <iostream>
#include <map>
#include <string>
#include <sstream>

 int main()
{
   std::string inputString;
   std::cout << "Enter the string = ";
   std::getline(std::cin, inputString);

   std::map<std::string, int> Map; // word, no. of times
   size_t wordCount = 0;
   size_t letterCount = 0;

   std::stringstream sstr(inputString);
   std::string word;

   while (std::getline(sstr, word, ' '))
   {
       Map[word]++;
       wordCount++;
       letterCount += word.size();
   }

   std::cout << "Total Words: " << wordCount << "\n\n";
   std::cout << "Total letters: " << letterCount << "\n\n";
   std::cout << "Each words count\n\n"  ;

   for(const auto& it: Map)
    std::cout << it.first << " " << it.second << " times\n";
   return 0;
}
