#include <iostream>
#include <string>

using namespace std;

bool isCommaOrSpace(char c)
{
   return c == ' ' || c == ',';
}

int main()
{
   string source = "   x  ,y  z  ,  a ,b, some text , ";
   string result = "";
   char last = ' ';
   for (unsigned int i=0; i<source.length(); i++)
   {
      if (source[i] != ' ' ||
          (!isCommaOrSpace(last) &&
           i < source.length()-1 && !isCommaOrSpace(source[i+1])))
      {
         result += source[i];
         last = source[i];
      }
   }

  cout << result << endl;

  int len;
  cin >> len;
  return 0;   
}
