#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
int ans = 1e9, n, r[10], f[10], dp[2][95][95][95], v[5005][10], s[5005][10],
    sum, cnt[10], lim[10], canhack[10];
int get(int S, int x) { return (S >> x) & 1; }
int check(int x, int S) {
  for (int i = 1; i <= 3; ++i)
    if (get(S, i - 1) && (!v[x][i])) return 0;
  return 1;
}
int sr[] = {0, 2, 4, 6, 8, 10, 12};
int score(int x, int S) {
  int ans = 0;
  for (int i = 1; i <= 3; ++i)
    if (s[x][i] && (!get(S, i - 1))) ans += sr[f[i]] * (250 - s[x][i]);
  return ans;
}
void dfs(int u) {
  if (u == 4) {
    for (int i = 1; i <= 3; ++i) {
      r[i] = std::min(canhack[i], cnt[i] - (lim[f[i] + 1] + 1));
      int l = cnt[i] - lim[f[i]];
      if (l > r[i]) return;
      if (r[i] < 0) return;
    }
    int scr = score(1, 0) + 100 * (r[1] + r[2] + r[3]);
    for (int j = 0; j <= r[1]; ++j)
      for (int k = 0; k <= r[2]; ++k)
        for (int l = 0; l <= r[3]; ++l) dp[0][j][k][l] = 1e9;
    dp[0][0][0][0] = 0;
    for (int i = 2; i <= n; ++i) {
      int x = i & 1;
      int y = x ^ 1;
      for (int j = 0; j <= r[1]; ++j)
        for (int k = 0; k <= r[2]; ++k)
          for (int l = 0; l <= r[3]; ++l) dp[y][j][k][l] = 1e9;
      for (int S = 0; S < (1 << 3); ++S) {
        int p1 = get(S, 0), p2 = get(S, 1), p3 = get(S, 2);
        if (check(i, S)) {
          for (int j = 0; j <= r[1]; ++j)
            for (int k = 0; k <= r[2]; ++k)
              for (int l = 0; l <= r[3]; ++l) {
                int &v = dp[y][j + p1][k + p2][l + p3];
                v = std::min(v, dp[x][j][k][l] + (score(i, S) > scr));
              }
        }
      }
    }
    ans = std::min(ans, dp[(n + 1) & 1][r[1]][r[2]][r[3]]);
    return;
  }
  for (int i = 1; i <= 6; ++i) {
    f[u] = i;
    dfs(u + 1);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= 3; ++j) {
      scanf("%d", &s[i][j]);
      if (s[i][j] != 0) {
        if (s[i][j] < 0) {
          s[i][j] *= -1;
          v[i][j] = 1;
          canhack[j]++;
          sum++;
        }
        cnt[j]++;
      }
    }
  }
  if (sum > 90) {
    puts("1");
    return 0;
  }
  for (int i = 0; i < 6; ++i) lim[i + 1] = n / (1 << i);
  lim[6 + 1] = -1;
  dfs(1);
  printf("%d", ans + 1);
  return 0;
}
