#include <bits/stdc++.h>
using namespace std;
const int MAX = 5050;
const int M = 6;
const int H = 90;
int lo[M], hi[M];
int pts[M];
int a[MAX][3];
int cur[MAX];
int cnt[3];
bool can[MAX][3];
int ac[3];
int main(void) {
  int n;
  scanf("%d", &n);
  for (int m = M - 1; m >= 0; --m) {
    hi[m] = n >> m;
    lo[m] = m + 1 == M ? 0 : hi[m + 1] + 1;
    pts[m] = (m + 1) * 500;
  }
  for (int i = (0); i < (n); ++i) {
    for (int j = (0); j < (3); ++j) {
      scanf("%d", &a[i][j]);
      if (a[i][j] < 0) {
        a[i][j] *= -1;
        can[i][j] = true;
        cnt[j]++;
      }
      if (a[i][j]) ac[j]++;
    }
  }
  if (cnt[0] + cnt[1] + cnt[2] >= H) {
    puts("1");
    return 0;
  }
  int ans = n;
  for (int x1 = (0); x1 < (M); ++x1)
    for (int x2 = (0); x2 < (M); ++x2)
      for (int x3 = (0); x3 < (M); ++x3) {
        int x[3] = {x1, x2, x3};
        int g[3];
        bool ok = true;
        for (int j = (0); j < (3); ++j) {
          if (lo[x[j]] > hi[x[j]]) ok = false;
          if (lo[x[j]] > ac[j]) ok = false;
          g[j] = min(ac[j] - lo[x[j]], cnt[j]);
          if (hi[x[j]] < ac[j] - g[j]) ok = false;
        }
        if (!ok) continue;
        int h = g[0] + g[1] + g[2];
        static int f[H][H][H];
        static int nf[H][H][H];
        const int inf = 1e9;
        for (int g0 = (0); g0 < (g[0] + 1); ++g0)
          for (int g1 = (0); g1 < (g[1] + 1); ++g1)
            for (int g2 = (0); g2 < (g[2] + 1); ++g2) f[g0][g1][g2] = inf;
        f[0][0][0] = 0;
        int off = 0;
        for (int i = (0); i < (n); ++i) {
          cur[i] = 0;
          for (int j = (0); j < (3); ++j)
            if (a[i][j]) cur[i] += pts[x[j]] * (250 - a[i][j]);
        }
        cur[0] += h * 250 * 100;
        for (int i = (1); i < (n); ++i) {
          if (can[i][0] || can[i][1] || can[i][2]) {
            for (int g0 = (0); g0 < (g[0] + 1); ++g0)
              for (int g1 = (0); g1 < (g[1] + 1); ++g1)
                for (int g2 = (0); g2 < (g[2] + 1); ++g2) nf[g0][g1][g2] = inf;
            for (int s = (0); s < (1 << 3); ++s) {
              bool ok = true;
              int nscore = cur[i];
              for (int j = (0); j < (3); ++j)
                if (s & (1 << j)) {
                  if (!can[i][j]) ok = false;
                  nscore -= pts[x[j]] * (250 - a[i][j]);
                }
              if (!ok) continue;
              for (int g0 = (0); g0 < (g[0] + 1); ++g0)
                for (int g1 = (0); g1 < (g[1] + 1); ++g1)
                  for (int g2 = (0); g2 < (g[2] + 1); ++g2) {
                    if (f[g0][g1][g2] == inf) continue;
                    int ng0 = g0 + (s & 1);
                    int ng1 = g1 + ((s >> 1) & 1);
                    int ng2 = g2 + ((s >> 2) & 1);
                    if (ng0 <= g[0] && ng1 <= g[1] && ng2 <= g[2]) {
                      nf[ng0][ng1][ng2] = min(
                          nf[ng0][ng1][ng2], f[g0][g1][g2] + (nscore > cur[0]));
                    }
                  }
            }
            for (int g0 = (0); g0 < (g[0] + 1); ++g0)
              for (int g1 = (0); g1 < (g[1] + 1); ++g1)
                for (int g2 = (0); g2 < (g[2] + 1); ++g2)
                  f[g0][g1][g2] = nf[g0][g1][g2];
          } else {
            if (cur[0] < cur[i]) off++;
          }
        }
        ans = min(ans, off + f[g[0]][g[1]][g[2]]);
      }
  printf("%d\n", ans + 1);
  return 0;
}
