#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

bool global_flag;

void solve(string hai, bool head) {
  if (global_flag) return;
  if (hai.empty()) {
    global_flag = true;
    return;
  }
  char c = hai[0];
  bool flag = true;
  string line0 = hai, line1 = hai, line2 = hai;
  // q
  for (int i = 0; i < 3; i += 1) {
    int idx = line0.find(c+i);
    if (idx == -1) {
      flag = false;
      break;
    }
    line0.erase(idx, 1);
  }
  if (flag) solve(line0, head);

  // q
  flag = true;
  for (int i = 0; i < 3; i += 1) {
    int idx = line1.find(c);
    if (idx == -1) {
      flag = false;
      break;
    }
    line1.erase(idx, 1);
  }
  if (flag) solve(line1, head);
  
  // ª
  if (!head) {
    flag = true;
    for (int i = 0; i < 2; i += 1) {
      int idx = line2.find(c);
      if (idx == -1) {
        flag = false;
        break;
      }
      line2.erase(idx, 1);
    }
    if (flag) solve(line2, true);
  }
}

int main(int argc, char const* argv[]) {
  string line;
  while (cin>>line) {
    bool printed = false;
    for (char c = '1'; c <= '9'; c += 1) {
      global_flag = false;
      string cline = line + c;
      if (count(cline.begin(), cline.end(), c) > 4) {
        continue;
      }
      
      sort(cline.begin(), cline.end());
      solve(cline, false);
      if (global_flag) {
        if (!printed) {
          printed = true;
          cout<<c;
        } else {
          cout<<" "<<c;
        }
      }
    }
    cout<<endl;
  }  
  return 0;
}