#include <vector>#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;char str[15];int cnt[4][14];int ctoi(char c){ if(c == 'm') return 0; if(c == 'p') return 1; if(c == 's') return 2; if(c == 'z') return 3;}int itoc(int i){ if(i == 0) return 'm'; if(i == 1) return 'p'; if(i == 2) return 's'; if(i == 3) return 'z';}bool dfs(){ for(int i=0;i<4;i++){ for(int j=1;j<=(i==3?7:9);j++){ if(!cnt[i][j]) continue; if(cnt[i][j]>= 3){ cnt[i][j] -= 3; if(dfs()){ cnt[i][j] += 3; return true; } cnt[i][j] += 3; } if(i != 3 && cnt[i][j] && cnt[i][j+1] && cnt[i][j+2]) { cnt[i][j]--;cnt[i][j+1]--;cnt[i][j+2]--; if(dfs()){ cnt[i][j]++;cnt[i][j+1]++;cnt[i][j+2]++; return true; } cnt[i][j]++;cnt[i][j+1]++;cnt[i][j+2]++; } return false; } } return true; }bool win(){ for(int i=0;i<4;i++){ for(int j=1;j<=(i==3?7:9);j++){ if(cnt[i][j] >= 2){ cnt[i][j] -= 2; if(dfs()){ cnt[i][j] += 2; return true; } cnt[i][j] += 2; } } } return false;}int main(){ while(~scanf("%s",str)) { memset(cnt,0,sizeof(cnt)); for(int i=0;str[i];i+=2){ cnt[ ctoi(str[i+1]) ][ str[i]-'0' ]++; } vector< pair<int,int> > ans; for(int i=0;i<4;i++){ for(int j=1;j<=(i==3?7:9);j++){ if(cnt[i][j] == 4) continue; cnt[i][j]++; if(win()) ans.push_back(make_pair(i,j)); cnt[i][j]--; } } printf("%d",(int)ans.size()); if((int)ans.size()){ putchar(' '); for(int i=0;i<(int)ans.size();i++) printf("%d%c",ans[i].second,itoc(ans[i].first)); } puts(""); } return 0;}