#include <bits/stdc++.h>
int main() {
  int n, i, j, k, l, m;
  int q[5][10];
  int a[105] = {0};
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    for (j = 0; j < 6; j++) {
      scanf("%d", &q[i][j]);
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 0; j < 6; j++) {
      a[q[i][j]] = 1;
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = i + 1; j <= n; j++) {
      for (k = 0; k < 6; k++) {
        for (l = 0; l < 6; l++) {
          int asd;
          asd = q[i][k] * 10 + q[j][l];
          a[asd] = 1;
          asd = q[i][k] + q[j][l] * 10;
          a[asd] = 1;
        }
      }
    }
  }
  for (i = 1; i < 100; i++) {
    if (a[i] == 0) {
      printf("%d\n", i - 1);
      break;
    }
  }
  return 0;
}
