#include <bits/stdc++.h>
using namespace std;
int n, subT[5003][3], score[3], numHack[3];
int cur = 0, pre = 1, dp[2][91][91][91];
int maxHack[3], numDone[3], ans = 1000000007;
int getScore(int u, int hackState) {
  int re = 0;
  for (int i = 0; i <= 2; i++)
    if (!((hackState >> i) & 1) && subT[u][i])
      re += score[i] * (250 - abs(subT[u][i])) / 250;
  return re;
}
bool canHack(int u) {
  return (subT[u][0] < 0) || (subT[u][1] < 0) || (subT[u][2] < 0);
}
int solve() {
  memset(dp, 0, sizeof(dp));
  int myScore = getScore(1, 0);
  for (int i = 0; i <= 2; i++) myScore += numHack[i] * 100;
  for (int u = 2; u <= n; u++)
    if (canHack(u) && getScore(u, 0) > myScore) {
      swap(cur, pre);
      for (int i = 0; i <= numHack[0]; i++)
        for (int j = 0; j <= numHack[1]; j++)
          for (int k = 0; k <= numHack[2]; k++)
            dp[cur][i][j][k] = dp[pre][i][j][k];
      for (int state = 1; state <= 8; state++)
        if (getScore(u, state) <= myScore) {
          bool ok = true;
          for (int i = 0; i <= 2; i++)
            if (((state >> i) & 1) && subT[u][i] >= 0) {
              ok = false;
              break;
            }
          if (!ok) continue;
          for (int i = ((state >> 0) & 1); i <= numHack[0]; i++)
            for (int j = ((state >> 1) & 1); j <= numHack[1]; j++)
              for (int k = ((state >> 2) & 1); k <= numHack[2]; k++)
                dp[cur][i][j][k] =
                    max(dp[cur][i][j][k],
                        dp[pre][i - ((state >> 0) & 1)][j - ((state >> 1) & 1)]
                          [k - ((state >> 2) & 1)] +
                            1);
        }
    }
  int re = 1 - dp[cur][numHack[0]][numHack[1]][numHack[2]];
  for (int u = 2; u <= n; u++)
    if (getScore(u, 0) > myScore) re++;
  return re;
}
void brute(int pos) {
  if (pos == 3) {
    ans = min(ans, solve());
    return;
  }
  for (int i = 1; i <= 6; i++) {
    int low = (i == 6 ? 0 : (n >> i) + 1);
    int hig = n >> (i - 1);
    if (numDone[pos] < low || numDone[pos] - maxHack[pos] > hig) continue;
    numHack[pos] = min(maxHack[pos], numDone[pos] - low);
    score[pos] = 500 * i;
    brute(pos + 1);
  }
}
void setup() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 2; j++) {
      cin >> subT[i][j];
      numDone[j] += (subT[i][j] != 0);
      maxHack[j] += (subT[i][j] < 0);
    }
}
void xuly() {
  if (maxHack[0] + maxHack[1] + maxHack[2] >= 90) {
    cout << 1;
    return;
  }
  brute(0);
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  setup();
  xuly();
  return 0;
}
