#include <bits/stdc++.h>
using namespace std;
inline long long Rd() {
  long long x = 0;
  int ch = getchar(), f = 1;
  while (!isdigit(ch) && (ch != '-') && (ch != EOF)) ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void Rt(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10)
    Rt(x / 10), putchar(x % 10 + '0');
  else
    putchar(x + '0');
}
const int N = 5005;
int n, a[N], b[N], c[N];
int Need(int Ds) {
  if (Ds == 0) return n + 1;
  if (Ds == 1) return n / 2 + 1;
  if (Ds == 2) return n / 4 + 1;
  if (Ds == 3) return n / 8 + 1;
  if (Ds == 4) return n / 16 + 1;
  if (Ds == 5) return n / 32 + 1;
  if (Ds == 6) return 0;
}
int Score(int Sc, int Tm) {
  if (!Tm) return 0;
  if (Tm < 0) Tm = -Tm;
  return Sc / 250 * (250 - Tm);
}
int Ca, Cb, Cc, Sa, Sb, Sc;
pair<int, int> Hq[N];
int Ks, Rank, Ans = (1 << 29);
int Max(int &a, int b) {
  if (a < b) a = b;
}
int F[2][95][95][95], S, T;
int main() {
  n = Rd();
  for (int i = 1; i <= (int)n; i++) {
    a[i] = Rd(), b[i] = Rd(), c[i] = Rd();
    if (a[i] < 0) Ca++;
    if (a[i]) Sa++;
    if (b[i] < 0) Cb++;
    if (b[i]) Sb++;
    if (c[i] < 0) Cc++;
    if (c[i]) Sc++;
  }
  if (Ca + Cb + Cc >= 90) return puts("1"), 0;
  for (int Fa = 1; Fa <= (int)6; Fa++)
    for (int Fb = 1; Fb <= (int)6; Fb++)
      for (int Fc = 1; Fc <= (int)6; Fc++) {
        int Na = Need(Fa), Nb = Need(Fb), Nc = Need(Fc);
        int Mxa = min(Ca, Sa - Na), Mxb = min(Cb, Sb - Nb),
            Mxc = min(Cc, Sc - Nc);
        if (Mxa < 0 || Sa - Mxa >= Need(Fa - 1)) continue;
        if (Mxb < 0 || Sb - Mxb >= Need(Fb - 1)) continue;
        if (Mxc < 0 || Sc - Mxc >= Need(Fc - 1)) continue;
        int Msc = (Mxa + Mxb + Mxc) * 100 + Score(Fa * 500, a[1]) +
                  Score(Fb * 500, b[1]) + Score(Fc * 500, c[1]);
        Ks = 0, Rank = 1;
        for (int i = 2; i <= (int)n; i++) {
          int Ts = Score(Fa * 500, a[i]) + Score(Fb * 500, b[i]) +
                   Score(Fc * 500, c[i]);
          if (Ts > Msc) {
            Rank++;
            if (a[i] < 0 || b[i] < 0 || c[i] < 0) Hq[++Ks] = make_pair(Ts, i);
          }
        }
        memset(F, 226, sizeof F);
        F[0][0][0][0] = 0;
        S = 0, T = 1;
        for (int i = 0; i <= (int)Ks - 1; i++) {
          for (int Ma = 0; Ma <= (int)Mxa; Ma++)
            for (int Mb = 0; Mb <= (int)Mxb; Mb++)
              for (int Mc = 0; Mc <= (int)Mxc; Mc++) {
                if (F[S][Ma][Mb][Mc] < 0) continue;
                int Val = F[S][Ma][Mb][Mc], Xh = Hq[i + 1].second,
                    Sc = Hq[i + 1].first;
                Ans = min(Ans, Rank - F[S][Ma][Mb][Mc]);
                Max(F[T][Ma][Mb][Mc], Val);
                if (Ma < Mxa && a[Xh] < 0 && Sc - Score(Fa * 500, a[Xh]) <= Msc)
                  Max(F[T][Ma + 1][Mb][Mc], Val + 1);
                if (Mb < Mxb && b[Xh] < 0 && Sc - Score(Fb * 500, b[Xh]) <= Msc)
                  Max(F[T][Ma][Mb + 1][Mc], Val + 1);
                if (Mc < Mxc && c[Xh] < 0 && Sc - Score(Fc * 500, c[Xh]) <= Msc)
                  Max(F[T][Ma][Mb][Mc + 1], Val + 1);
                if (Ma < Mxa && Mb < Mxb && a[Xh] < 0 && b[Xh] < 0 &&
                    Score(Fc * 500, c[Xh]) <= Msc)
                  Max(F[T][Ma + 1][Mb + 1][Mc], Val + 1);
                if (Ma < Mxa && Mc < Mxc && a[Xh] < 0 && c[Xh] < 0 &&
                    Score(Fb * 500, b[Xh]) <= Msc)
                  Max(F[T][Ma + 1][Mb][Mc + 1], Val + 1);
                if (Mb < Mxb && Mc < Mxc && b[Xh] < 0 && c[Xh] < 0 &&
                    Score(Fa * 500, a[Xh]) <= Msc)
                  Max(F[T][Ma][Mb + 1][Mc + 1], Val + 1);
                if (Ma < Mxa && Mb < Mxb && Mc < Mxc && a[Xh] < 0 &&
                    b[Xh] < 0 && c[Xh] < 0)
                  Max(F[T][Ma + 1][Mb + 1][Mc + 1], Val + 1);
              }
          S ^= 1, T ^= 1;
        }
        for (int Ma = 0; Ma <= (int)Mxa; Ma++)
          for (int Mb = 0; Mb <= (int)Mxb; Mb++)
            for (int Mc = 0; Mc <= (int)Mxc; Mc++)
              Ans = min(Ans, Rank - F[S][Ma][Mb][Mc]);
      }
  Rt(Ans);
}
