#include <bits/stdc++.h>
using namespace std;
int ololo[5000][3], n, s[3], h[3], score[3], tag[3], ans, dp[2][90][90][90],
    now, pre;
int minn, maxx;
int calc(int sc, int tm) {
  if (tm == 0) return 0;
  return sc * (250 - abs(tm)) / 250;
}
int sc(int l) {
  int sum = 0;
  for (int i = 0; i < 3; i++) sum += calc(score[i], ololo[l][i]);
  return sum;
}
int solve() {
  memset(dp, 0, sizeof dp);
  int my = 0, ret = 0;
  for (int i = 0; i < 3; i++) my += 100 * tag[i] + calc(score[i], ololo[0][i]);
  now = 0;
  pre = 1;
  for (int l = 1; l < n; l++)
    if (sc(l) > my) {
      now ^= 1;
      pre ^= 1;
      ++ret;
      for (int i = 0; i <= tag[0]; i++)
        for (int j = 0; j <= tag[1]; j++)
          for (int k = 0; k <= tag[2]; k++) dp[now][i][j][k] = dp[pre][i][j][k];
      for (int ii = 0; ii < 2; ii++)
        for (int jj = 0; jj < 2; jj++)
          for (int kk = 0; kk < 2; kk++) {
            if (ii == 1 && ololo[l][0] >= 0) continue;
            if (jj == 1 && ololo[l][1] >= 0) continue;
            if (kk == 1 && ololo[l][2] >= 0) continue;
            int s = calc(score[0], ololo[l][0]) * (ii ^ 1) +
                    calc(score[1], ololo[l][1]) * (jj ^ 1) +
                    calc(score[2], ololo[l][2]) * (kk ^ 1);
            if (s > my) continue;
            for (int i = ii; i <= tag[0]; i++)
              for (int j = jj; j <= tag[1]; j++)
                for (int k = kk; k <= tag[2]; k++)
                  dp[now][i][j][k] = max(dp[now][i][j][k],
                                         dp[pre][i - ii][j - jj][k - kk] + 1);
          }
    }
  ret += 1 - dp[now][tag[0]][tag[1]][tag[2]];
  return ret;
}
void dfs(int k) {
  if (k == 3) {
    ans = min(solve(), ans);
    return;
  }
  for (int i = 1; i <= 6; i++) {
    minn = i == 6 ? 0 : (n >> i) + 1, maxx = n >> i - 1;
    if (s[k] >= minn && s[k] - h[k] <= maxx)
      score[k] = 500 * i, tag[k] = min(h[k], s[k] - minn), dfs(k + 1);
  }
}
int main() {
  memset(s, 0, sizeof s);
  memset(h, 0, sizeof h);
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 3; j++) {
      scanf("%d", &ololo[i][j]);
      s[j] += ololo[i][j] != 0;
      h[j] += ololo[i][j] < 0;
    }
  if (h[0] + h[1] + h[2] > 89) {
    printf("1\n");
    return 0;
  }
  ans = n;
  dfs(0);
  printf("%d\n", ans);
  return 0;
}
