#include #include #include static int id(const char *s) { int row = 0, col = 0, size = 128; while (*s == 'F' || *s == 'B') { size /= 2; if (*s++ == 'B') row += size; } size = 8; while (*s) { size /= 2; if (*s++ == 'R') col += size; } return row * 8 + col; } int main(void) { char s[11]; int max = 0; bool ids[1024] = {0}; while (EOF != scanf("%s\n", s)) { if (id(s) > max) max = id(s); ids[id(s)] = true; } printf("%d\n", max); for (int i = 1; i < 1024; ++i) { if (ids[i-1] && !ids[i]) { printf("%d\n", i); break; } } }