#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
const int N = 5010;
int n, mt[N][3], sco[N][3], sol[10], hc[10], sv[N][30];
int dp[110][110][110];
vector<int> hs[N];
int ff(int n, int p, int id) {
  int v = (n >> (p + 1)) + 1;
  if (p == 5) v = 0;
  if ((v << p) > n) return -1;
  if (v > sol[id]) return -1;
  if (((sol[id] - hc[id]) << p) > n) return -1;
  return min(sol[id] - v, hc[id]);
}
int gg(int mt, int p) {
  if (mt == 0) return 0;
  if (mt < 0) mt *= -1;
  return (p + 1) * 2 * (250 - mt);
}
inline void upd(int &a, int b) {
  if (a > b) a = b;
}
int main() {
  scanf("%d", &n);
  int tot = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      scanf("%d", &mt[i][j]);
      if (mt[i][j] != 0) sol[j]++;
      if (mt[i][j] < 0) tot++, hc[j]++;
    }
    for (int S = 0; S < 8; S++)
      if ((mt[i][0] < 0 || (S & 1) == 0) && (mt[i][1] < 0 || (S & 2) == 0) &&
          (mt[i][2] < 0 || (S & 4) == 0))
        hs[i].push_back(S);
  }
  if (tot > 90) {
    puts("1");
    return 0;
  }
  int ans = n;
  for (int p1 = 0; p1 < 6; p1++)
    for (int p2 = 0; p2 < 6; p2++)
      for (int p3 = 0; p3 < 6; p3++) {
        int h1 = ff(n, p1, 0), h2 = ff(n, p2, 1), h3 = ff(n, p3, 2);
        if (h1 < 0 || h2 < 0 || h3 < 0) continue;
        for (int i = 0; i < n; i++) {
          sco[i][0] = gg(mt[i][0], p1);
          sco[i][1] = gg(mt[i][1], p2);
          sco[i][2] = gg(mt[i][2], p3);
          for (auto S : hs[i]) {
            int sc = 0;
            for (int j = 0; j < 3; j++)
              if ((S & (1 << j)) == 0) sc += sco[i][j];
            sv[i][S] = sc;
          }
        }
        int ss = sco[0][0] + sco[0][1] + sco[0][2] + 100 * (h1 + h2 + h3);
        int pre = 1;
        memset(dp, 0x20, sizeof(dp));
        dp[0][0][0] = 0;
        int l1 = 0, l2 = 0, l3 = 0;
        for (int i = 1; i < n; i++) {
          if (mt[i][0] >= 0 && mt[i][1] >= 0 && mt[i][2] >= 0) {
            pre += (sco[i][0] + sco[i][1] + sco[i][2]) > ss;
            continue;
          }
          for (int v1 = l1 + 1 - 1; v1 >= 0; v1--)
            for (int v2 = l2 + 1 - 1; v2 >= 0; v2--)
              for (int v3 = l3 + 1 - 1; v3 >= 0; v3--) {
                for (auto S : hs[i])
                  upd(dp[v1 + ((S >> 0) & 1)][v2 + ((S >> 1) & 1)]
                        [v3 + ((S >> 2) & 1)],
                      dp[v1][v2][v3] + (sv[i][S] > ss));
                dp[v1][v2][v3] += (sv[i][0] > ss);
              }
          l1 = min(h1, l1 + (mt[i][0] < 0));
          l2 = min(h2, l2 + (mt[i][1] < 0));
          l3 = min(h3, l3 + (mt[i][2] < 0));
        }
        ans = min(ans, pre + dp[h1][h2][h3]);
      }
  printf("%d\n", ans);
}
