#include <bits/stdc++.h>
using namespace std;
const int N = 5050, M = 92, oo = 1000000000;
int pa, pb, pc, ia, ib, ic, ja, jb, jc, i, j, k, n, ch, ff, t, sa, sb, sc, ans,
    ka, kb, kc, na, nb, nc, ma, mb, mc, la, lb, lc, ra, rb, rc, ta, tb, tc, tt,
    tmp, maxa, maxb, maxc, ttt, num;
int f[M][M][M];
struct cc {
  int a, b, c;
} A[N];
void R(int &x) {
  x = ff = 0;
  ch = getchar();
  while (ch < '0' || '9' < ch) {
    if (ch == '-') ff = 1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  if (ff) x = -x;
}
int abs(int x) {
  if (x < 0) return -x;
  return x;
}
int max(int x, int y) {
  if (x > y) return x;
  return y;
}
int main() {
  R(n);
  for (i = 1; i <= n; i++) {
    R(A[i].a);
    R(A[i].b);
    R(A[i].c);
    if (A[i].a > 0) na++;
    if (A[i].b > 0) nb++;
    if (A[i].c > 0) nc++;
    if (A[i].a < 0) ma++;
    if (A[i].b < 0) mb++;
    if (A[i].c < 0) mc++;
  }
  t = (ma + mb + mc) * 100;
  ra = 1;
  while (ra < 6 && (1 << ra) * na <= n) ra++;
  sa = 500 * ra;
  rb = 1;
  while (rb < 6 && (1 << rb) * nb <= n) rb++;
  sb = 500 * rb;
  rc = 1;
  while (rc < 6 && (1 << rc) * nc <= n) rc++;
  sc = 500 * rc;
  if (A[1].a) t += sa * (250 - A[1].a) / 250;
  if (A[1].b) t += sb * (250 - A[1].b) / 250;
  if (A[1].c) t += sc * (250 - A[1].c) / 250;
  ans = 1;
  for (i = 2; i <= n; i++) {
    tt = 0;
    if (A[i].a > 0) tt += sa * (250 - A[i].a) / 250;
    if (A[i].b > 0) tt += sb * (250 - A[i].b) / 250;
    if (A[i].c > 0) tt += sc * (250 - A[i].c) / 250;
    if (tt > t) ans++;
  }
  if (ans == 1) return puts("1"), 0;
  la = 1;
  while (la < 6 && (1 << la) * (na + ma) <= n) la++;
  lb = 1;
  while (lb < 6 && (1 << lb) * (nb + mb) <= n) lb++;
  lc = 1;
  while (lc < 6 && (1 << lc) * (nc + mc) <= n) lc++;
  for (ka = la; ka <= ra; ka++) {
    sa = ka * 500;
    ta = n / (1 << ka) + 1;
    if (ka == 6) ta = 0;
    if (ta < na) ta = na;
    ta = na + ma - ta;
    for (kb = lb; kb <= rb; kb++) {
      sb = kb * 500;
      tb = n / (1 << kb) + 1;
      if (kb == 6) tb = 0;
      if (tb < nb) tb = nb;
      tb = nb + mb - tb;
      for (kc = lc; kc <= rc; kc++) {
        sc = kc * 500;
        tc = n / (1 << kc) + 1;
        if (kc == 6) tc = 0;
        if (tc < nc) tc = nc;
        tc = nc + mc - tc;
        t = 100 * (ta + tb + tc);
        if (A[1].a) t += sa * (250 - A[1].a) / 250;
        if (A[1].b) t += sb * (250 - A[1].b) / 250;
        if (A[1].c) t += sc * (250 - A[1].c) / 250;
        tmp = 1;
        maxa = maxb = maxc = 0;
        for (i = 2; i <= n; i++) {
          tt = 0;
          if (A[i].a) tt += sa * (250 - abs(A[i].a)) / 250;
          if (A[i].b) tt += sb * (250 - abs(A[i].b)) / 250;
          if (A[i].c) tt += sc * (250 - abs(A[i].c)) / 250;
          if (tt <= t) continue;
          if (A[i].a < 0) maxa++;
          if (A[i].b < 0) maxb++;
          if (A[i].c < 0) maxc++;
        }
        if (maxa > ta) maxa = ta;
        if (maxb > tb) maxb = tb;
        if (maxc > tc) maxc = tc;
        for (ia = 0; ia <= maxa; ia++)
          for (ib = 0; ib <= maxb; ib++)
            for (ic = 0; ic <= maxc; ic++) f[ia][ib][ic] = -oo;
        f[0][0][0] = 0;
        maxa = maxb = maxc = 0;
        for (i = 2; i <= n; i++) {
          tt = 0;
          if (A[i].a) tt += sa * (250 - abs(A[i].a)) / 250;
          if (A[i].b) tt += sb * (250 - abs(A[i].b)) / 250;
          if (A[i].c) tt += sc * (250 - abs(A[i].c)) / 250;
          if (tt <= t) continue;
          tmp++;
          if (A[i].a >= 0 && A[i].b >= 0 && A[i].c >= 0) continue;
          if (A[i].a < 0)
            ja = 1;
          else
            ja = 0;
          if (A[i].b < 0)
            jb = 1;
          else
            jb = 0;
          if (A[i].c < 0)
            jc = 1;
          else
            jc = 0;
          maxa += ja;
          maxb += jb;
          maxc += jc;
          if (maxa > ta) maxa = ta;
          if (maxb > tb) maxb = tb;
          if (maxc > tc) maxc = tc;
          pa = ja;
          pb = jb;
          pc = jc;
          for (ia = maxa; ia >= 0; ia--)
            for (ib = maxb; ib >= 0; ib--)
              for (ic = maxc; ic >= 0; ic--)
                for (ja = 0; ja <= pa; ja++)
                  for (jb = 0; jb <= pb; jb++)
                    for (jc = 0; jc <= pc; jc++)
                      if (ia >= ja && ib >= jb && ic >= jc &&
                          tt - ja * sa * (250 - abs(A[i].a)) / 250 -
                                  jb * sb * (250 - abs(A[i].b)) / 250 -
                                  jc * sc * (250 - abs(A[i].c)) / 250 <=
                              t)
                        f[ia][ib][ic] = max(f[ia][ib][ic],
                                            f[ia - ja][ib - jb][ic - jc] + 1);
        }
        ttt = 0;
        for (ia = 0; ia <= maxa; ia++)
          for (ib = 0; ib <= maxb; ib++)
            for (ic = 0; ic <= maxc; ic++) ttt = max(ttt, f[ia][ib][ic]);
        if (tmp - ttt < ans) ans = tmp - ttt;
      }
    }
  }
  printf("%d\n", ans);
}
