#include <bits/stdc++.h>
using namespace std;
const int N = 5010;
int gi() {
  int w = 0;
  bool q = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') q = 0, c = getchar();
  while (c >= '0' && c <= '9') w = w * 10 + c - '0', c = getchar();
  return q ? w : -w;
}
int f[90][90][90], g[90][90][90], ta[N], tb[N], tc[N];
bool hacka[N], hackb[N], hackc[N];
inline void upd(int &x, int y) { x < y ? x = y : 0; }
int main() {
  int n = gi(), i, k, la = 0, lb = 0, lc = 0, wa = 0, wb = 0, wc = 0, a, b, c,
      sa, sb, sc, ea, eb, ec, ans = 0, p, pa, pb, pc, ma, mb, mc;
  for (i = 1; i <= n; i++) {
    if (!(k = gi()))
      k = 250;
    else if (wa++, k < 0)
      la++, k = -k, hacka[i] = true;
    ta[i] = (250 - k);
    if (!(k = gi()))
      k = 250;
    else if (wb++, k < 0)
      lb++, k = -k, hackb[i] = true;
    tb[i] = (250 - k);
    if (!(k = gi()))
      k = 250;
    else if (wc++, k < 0)
      lc++, k = -k, hackc[i] = true;
    tc[i] = (250 - k);
  }
  if (la + lb + lc >= 90) return puts("1"), 0;
  const int point[7] = {0, 3000, 2500, 2000, 1500, 1000, 500};
  const int lim[7] = {-1, n / 32, n / 16, n / 8, n / 4, n / 2, n};
  for (a = 1; a <= 6; a++)
    if (lim[a - 1] < wa && wa - la <= lim[a])
      for (b = 1; b <= 6; b++)
        if (lim[b - 1] < wb && wb - lb <= lim[b])
          for (c = 1; c <= 6; c++)
            if (lim[c - 1] < wc && wc - lc <= lim[c]) {
              f[sa = 0][sb = 0][sc = 0] = 0;
              p = point[a] * ta[1] + point[b] * tb[1] + point[c] * tc[1] +
                  ((ma = min(wa - lim[a - 1] - 1, la)) +
                   (mb = min(wb - lim[b - 1] - 1, lb)) +
                   (mc = min(wc - lim[c - 1] - 1, lc))) *
                      100 * 250;
              for (i = 2; i <= n; i++) {
                pa = point[a] * ta[i];
                pb = point[b] * tb[i];
                pc = point[c] * tc[i];
                for (ea = 0; ea <= sa; ea++)
                  for (eb = 0; eb <= sb; eb++)
                    for (ec = 0; ec <= sc; ec++) {
                      k = f[ea][eb][ec];
                      upd(g[ea][eb][ec], k + (p >= pa + pb + pc));
                      if (hacka[i]) upd(g[ea + 1][eb][ec], k + (p >= pb + pc));
                      if (hackb[i]) upd(g[ea][eb + 1][ec], k + (p >= pa + pc));
                      if (hackc[i]) upd(g[ea][eb][ec + 1], k + (p >= pa + pb));
                      if (hacka[i] && hackb[i])
                        upd(g[ea + 1][eb + 1][ec], k + (p >= pc));
                      if (hacka[i] && hackc[i])
                        upd(g[ea + 1][eb][ec + 1], k + (p >= pb));
                      if (hackb[i] && hackc[i])
                        upd(g[ea][eb + 1][ec + 1], k + (p >= pa));
                      if (hacka[i] && hackb[i] && hackc[i])
                        upd(g[ea + 1][eb + 1][ec + 1], k + 1);
                    }
                sa += hacka[i], sb += hackb[i], sc += hackc[i];
                for (ea = 0; ea <= sa; ea++)
                  for (eb = 0; eb <= sb; eb++)
                    for (ec = 0; ec <= sc; ec++)
                      f[ea][eb][ec] = g[ea][eb][ec], g[ea][eb][ec] = 0;
                if (sa > ma) sa--;
                if (sb > mb) sb--;
                if (sc > mc) sc--;
              }
              ans = max(ans, f[ma][mb][mc]);
            }
  printf("%d\n", n - ans);
  return 0;
}
