#include <bits/stdc++.h>
using namespace std;
int fen[7] = {1, 2, 4, 8, 16, 32, -1};
const int maxn = 5005;
int dp[100][100][100];
struct pi {
  int a, b, c;
} pp[maxn], pp1[maxn];
int getpoi(pi x, int a, int b, int c) {
  a = 500 * (a + 1);
  b = 500 * (b + 1);
  c = 500 * (c + 1);
  int s = 0;
  if (x.a != 0) s += a * (250 - abs(x.a)) / 250;
  if (x.b != 0) s += b * (250 - abs(x.b)) / 250;
  if (x.c != 0) s += c * (250 - abs(x.c)) / 250;
  return s;
}
int get(int a, int n) {
  int a1 = n / fen[a];
  int a2 = n / fen[a + 1] + 1;
  a2 = max(a2, 0);
  int x = 0, y = 0;
  for (int i = 1; i <= n; i++) {
    if (pp[i].a == 0) continue;
    if (pp[i].a > 0)
      x++;
    else
      y++;
  }
  if (x + y < a2) return n + 1;
  if (x > a1) return n + 1;
  int w = x + y - a2;
  w = min(w, y);
  return w;
}
int get1(int a, int n) {
  int a1 = n / fen[a];
  int a2 = n / fen[a + 1] + 1;
  a2 = max(a2, 0);
  int x = 0, y = 0;
  for (int i = 1; i <= n; i++) {
    if (pp[i].b == 0) continue;
    if (pp[i].b > 0)
      x++;
    else
      y++;
  }
  if (x + y < a2) return n + 1;
  if (x > a1) return n + 1;
  int w = x + y - a2;
  w = min(w, y);
  return w;
}
int get2(int a, int n) {
  int a1 = n / fen[a];
  int a2 = n / fen[a + 1] + 1;
  a2 = max(a2, 0);
  int x = 0, y = 0;
  for (int i = 1; i <= n; i++) {
    if (pp[i].c == 0) continue;
    if (pp[i].c > 0)
      x++;
    else
      y++;
  }
  if (x + y < a2) return n + 1;
  if (x > a1) return n + 1;
  int w = x + y - a2;
  w = min(w, y);
  return w;
}
int solve(int a, int b, int c, int n) {
  int x = get(a, n);
  if (x == n + 1) return n + 1;
  int y = get1(b, n);
  if (y == n + 1) return n + 1;
  int z = get2(c, n);
  if (z == n + 1) return n + 1;
  int p = getpoi(pp[1], a, b, c);
  p += (x + y + z) * 100;
  int tot = 0;
  int s = 0;
  for (int i = 2; i <= n; i++) {
    int q = getpoi(pp[i], a, b, c);
    if (q > p && (pp[i].a < 0 || pp[i].b < 0 || pp[i].c < 0))
      pp1[tot++] = pp[i];
    if (q > p) s++;
  }
  if (tot == 0) return s + 1;
  for (int i = 0; i <= x; i++) {
    for (int j = 0; j <= y; j++) {
      for (int f = 0; f <= z; f++) {
        dp[i][j][f] = 0;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < tot; i++) {
    for (int j = x; j >= 0; j--) {
      for (int f = y; f >= 0; f--) {
        for (int w = z; w >= 0; w--) {
          pi pp2 = pp1[i];
          int mask = 0;
          if (pp1[i].a < 0) mask |= 1;
          if (pp1[i].b < 0) mask |= 2;
          if (pp1[i].c < 0) mask |= 4;
          for (int u = mask; u; u = (u - 1) & mask) {
            pp2 = pp1[i];
            int x1 = 0, y1 = 0, z1 = 0;
            if (u & 1) {
              if (j == 0) continue;
              pp2.a = 0;
              x1 = 1;
            }
            if (u & 2) {
              if (f == 0) continue;
              pp2.b = 0;
              y1 = 1;
            }
            if (u & 4) {
              if (w == 0) continue;
              pp2.c = 0;
              z1 = 1;
            }
            if (getpoi(pp2, a, b, c) <= p) {
              dp[j][f][w] = max(dp[j][f][w], dp[j - x1][f - y1][w - z1] + 1);
            }
          }
          ans = max(ans, dp[j][f][w]);
        }
      }
    }
  }
  return s + 1 - ans;
}
int main() {
  int i, j, n, m;
  cin >> n;
  int ans = n + 1;
  for (int i = 1; i <= n; i++) scanf("%d%d%d", &pp[i].a, &pp[i].b, &pp[i].c);
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < 6; j++) {
      for (int f = 0; f < 6; f++) {
        ans = min(ans, solve(i, j, f, n));
      }
    }
  }
  cout << ans << endl;
}
