#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int n;
int t[5555][3], solve[3], canHack[3], willHack[3], score[3];
int dp[2][90][90][90];
int calc(int s, int t) {
  if (t == 0) return 0;
  return s * (250 - abs(t)) / 250;
}
int DP() {
  int myscore = 0;
  for (int i = 0; i < 3; ++i) {
    myscore += calc(score[i], t[0][i]) + willHack[i] * 100;
  }
  memset(dp, 0, sizeof dp);
  int cur = 0, pre = 1;
  int sum = 0;
  for (int p = 1; p < n; ++p) {
    if (t[p][0] >= 0 && t[p][1] >= 0 && t[p][2] >= 0) {
      int othscore = calc(score[0], t[p][0]) + calc(score[1], t[p][1]) +
                     calc(score[2], t[p][2]);
      sum += (othscore <= myscore);
      continue;
    }
    swap(cur, pre);
    memset(dp[cur], 0, sizeof dp[cur]);
    for (int a = 0; a < 8; ++a) {
      int othscore = 0;
      bool flag = true;
      for (int b = 0; b < 3; ++b) {
        if (((a >> b) & 1) == 0)
          othscore += calc(score[b], t[p][b]);
        else if (t[p][b] >= 0)
          flag = false;
      }
      if (othscore > myscore && a) continue;
      if (flag) {
        int ii = (a >> 0) & 1;
        int jj = (a >> 1) & 1;
        int kk = (a >> 2) & 1;
        for (int i = 0; i + ii <= willHack[0]; ++i) {
          for (int j = 0; j + jj <= willHack[1]; ++j) {
            for (int k = 0; k + kk <= willHack[2]; ++k) {
              dp[cur][i + ii][j + jj][k + kk] =
                  max(dp[cur][i + ii][j + jj][k + kk],
                      dp[pre][i][j][k] + (othscore <= myscore));
            }
          }
        }
      }
    }
  }
  return n - dp[cur][willHack[0]][willHack[1]][willHack[2]] - sum;
}
void dfs(int k, int &ans) {
  if (k == 3) {
    ans = min(ans, DP());
    return;
  }
  willHack[k] = 0;
  for (int num = n, sc = 500; num && sc <= 3000; num /= 2, sc += 500) {
    int r = num, l = num / 2;
    if (sc == 3000) l = 0;
    if (solve[k] > l && solve[k] - canHack[k] <= r) {
      score[k] = sc;
      willHack[k] = min(solve[k] - l - 1, canHack[k]);
      dfs(k + 1, ans);
    }
  }
  if (canHack[k] == solve[k]) {
    willHack[k] = canHack[k];
    dfs(k + 1, ans);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      scanf("%d", &t[i][j]);
      if (t[i][j]) solve[j]++;
      if (t[i][j] < 0) canHack[j]++;
    }
  }
  if (canHack[0] + canHack[1] + canHack[2] >= 90) {
    puts("1");
  } else {
    int ans = n;
    dfs(0, ans);
    printf("%d\n", ans);
  }
  return 0;
}
