#include #include #include #include #include #include #include #include #include #include #include #include #define FOR(i, a, b) for(int i=(a);i<=(b);i++) #define RFOR(i, a, b) for(int i=(a);i>=(b);i--) #define MOD 1000000007 #define INF 1000000000 using namespace std; int main(void) { int n; bool dp[10]; cin >> n; FOR(i, 0, 9) { dp[i] = false; } FOR(i, 1, n) { int a, b, c, d; string r; cin >> a >> b >> c >> d >> r; if (r == "NO") { dp[a] = true; dp[b] = true; dp[c] = true; dp[d] = true; } } FOR(i, 0, 9) { if (dp[i] == false) { cout << i << endl; break; } } return 0; }