#include <iostream>
#include <regex>
#include <string>
#include <vector>

bool reg_match(const std::regex& r, const std::string& s) {
   return std::regex_search(s, r);
}

int main( ) {
   std::string s;
   std::regex r(R"(^(.*[\s,])?UAM([\s,].*)?$)");
   while (std::getline(std::cin, s)) {
      std::cout << reg_match(r, s) << "\n";
   }
}

/* Ejemplo de entrada:
UAM :)
:) UAM
La,UAM,Azc
adecUAMos
UAM
UAMwww
wwwUAM
*/
