#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "Possible" : "Impossible");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  x += y;
  if (x >= mod) x -= mod;
}
void et() {
  puts("-1");
  exit(0);
}
int ftm[5005][3], canHack[3], solved[3], willHack[3], points[3];
int calScore(int sc, int time) {
  if (time == 0) return 0;
  return sc * (250 - abs(time)) / 250;
}
int calTotalScore(int who) {
  int myScore = 0;
  for (int(j) = 0; (j) < (int)(3); (j)++)
    myScore += calScore(points[j], ftm[who][j]);
  return myScore;
}
int dp[2][90][90][90], Ans = (1 << 30);
int cal() {
  memset(dp, 0, sizeof dp);
  int myScore = 100 * (willHack[0] + willHack[1] + willHack[2]);
  myScore += calTotalScore(1);
  int t = 0, cnt = 0;
  for (int i = 2; i <= n; i++) {
    if (calTotalScore(i) <= myScore) continue;
    cnt++;
    int cur = t ^ 1, pre = t;
    for (int(ii) = 0; (ii) < (int)(willHack[0] + 1); (ii)++)
      for (int(jj) = 0; (jj) < (int)(willHack[1] + 1); (jj)++)
        for (int(kk) = 0; (kk) < (int)(willHack[2] + 1); (kk)++)
          dp[cur][ii][jj][kk] = dp[pre][ii][jj][kk];
    for (int(ii) = 0; (ii) < (int)(2); (ii)++)
      for (int(jj) = 0; (jj) < (int)(2); (jj)++)
        for (int(kk) = 0; (kk) < (int)(2); (kk)++) {
          if (ii == 1 && ftm[i][0] >= 0) continue;
          if (jj == 1 && ftm[i][1] >= 0) continue;
          if (kk == 1 && ftm[i][2] >= 0) continue;
          int tmpScore = 0;
          if (!ii) tmpScore += calScore(points[0], ftm[i][0]);
          if (!jj) tmpScore += calScore(points[1], ftm[i][1]);
          if (!kk) tmpScore += calScore(points[2], ftm[i][2]);
          if (tmpScore >= myScore) continue;
          for (int x = ii; x <= willHack[0]; x++) {
            for (int y = jj; y <= willHack[1]; y++) {
              for (int z = kk; z <= willHack[2]; z++) {
                dp[cur][x][y][z] =
                    max(dp[cur][x][y][z], dp[pre][x - ii][y - jj][z - kk] + 1);
              }
            }
          }
        }
    t ^= 1;
  }
  int ans = dp[t][willHack[0]][willHack[1]][willHack[2]];
  return cnt - ans + 1;
}
void dfs(int i) {
  if (i == 3) {
    int res = cal();
    Ans = min(Ans, res);
    return;
  }
  int pre = n, co = 2;
  for (int(j) = 0; (j) < (int)(6); (j)++) {
    int low = n / co + 1;
    if (pre < low) {
      if (canHack[i] == solved[i]) {
        willHack[i] = canHack[i];
        points[i] = 3000;
        dfs(i + 1);
      }
      return;
    }
    co *= 2;
    int R = min(solved[i], pre);
    int L = max(solved[i] - canHack[i], low);
    if (L <= R) {
      willHack[i] = min(solved[i] - L, canHack[i]);
      points[i] = 500 * (j + 1);
      dfs(i + 1);
    }
    pre = low - 1;
  }
}
void fmain() {
  scanf("%d", &n);
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    for (int(j) = 0; (j) < (int)(3); (j)++) {
      scanf("%d", &ftm[i][j]);
      canHack[j] += ftm[i][j] < 0;
      solved[j] += ftm[i][j] != 0;
    }
  }
  if (canHack[0] + canHack[1] + canHack[2] >= 90) {
    puts("1");
    return;
  }
  dfs(0);
  printf("%d\n", Ans);
}
int main() {
  fmain();
  return 0;
}
