#include <bits/stdc++.h>
using namespace std;
int64_t inf = 1000 * 1000 * 1000;
int64_t inf64 = inf * inf;
int64_t mod = 228228227;
int64_t nll = 0;
int64_t ans[100];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr << fixed << setprecision(8);
  srand(time(0));
  auto START_TIME = chrono::high_resolution_clock::now();
  int32_t n;
  cin >> n;
  int64_t a[n * 6];
  for (int32_t i = 0; i < 6 * n; ++i) cin >> a[i];
  for (int32_t i = 0; i < 6 * n; ++i) {
    ans[a[i]] = 1;
    for (int32_t j = 0; j < 6 * n; ++j) {
      if (i / 6 != j / 6) {
        ans[a[i] * 10 + a[j]] = 1;
      }
    }
  }
  int32_t idx = 0;
  while (ans[idx + 1]) ++idx;
  cout << idx;
  cerr << endl
       << chrono::duration<long double>(chrono::high_resolution_clock::now() -
                                        START_TIME)
              .count()
       << " sec.";
}
