#include <iostream>

namespace ISR
{
    // returns length, string in str
    int SmashCasePunct( std::string & str )
    {
      std::string output;

      // smash case, skip punctuation
      for ( std::string::const_iterator iter = str.begin(); iter != str.end(); iter++ )
      {
        char x = tolower((*iter));

        // skip punctuation, save hypens
        if ( ispunct(x) && (x != '-'))
         continue;

        output += x;
      }

      str = output; // copy

      return str.length();
    }

    // returns string length and lowercase/nonpunctuated string in output
    int ScanAlnum( std::string & output )
    {
       int length = 0;    // hold word length

       // ignore words longer then 25 characters and shorter then 3
       while ( length < 3 || length > 25 )
       {
         output = "";       // clear the string

         if ( std::cin.eof() )   // if we hit the end of input then return 0
          return 0;

         std::cin >> output;     // pull in a word

         if ( !isdigit(output[0]) )
          length = SmashCasePunct( output );    // smash the case and punctuation
         else
          length = 0; // ignore words that start with a digit
       }

       return length;
    }
};