#include <bits/stdc++.h>
using namespace std;
int n, a[5006], b[5005], c[5005], W[10], L[10], R[10], wa, wb, wc, sa, sb, sc,
    A, B, C, ans, tmp, be, me, i1, i2, i3, p1, p2, p3, f[100][100][100],
    g[100][100][100];
int get(int a, int b, int c) {
  return W[i1] * (250 - abs(a)) + W[i2] * (250 - abs(b)) +
         W[i3] * (250 - abs(c));
}
int main() {
  memset(f, -1, sizeof f);
  memset(g, -1, sizeof g);
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d%d", &a[i], &b[i], &c[i]);
    if (a[i]) ++sa;
    if (a[i] < 0) ++wa;
    if (b[i]) ++sb;
    if (b[i] < 0) ++wb;
    if (c[i]) ++sc;
    if (c[i] < 0) ++wc;
    if (!a[i]) a[i] = 250;
    if (!b[i]) b[i] = 250;
    if (!c[i]) c[i] = 250;
  }
  if (wa + wb + wc > 89) {
    puts("1");
    return 0;
  }
  for (int i = 1; i <= 6; ++i) {
    W[i] = i * 2;
    L[i] = ceil(1.0 * n / (1 << i) + 0.000000001);
    R[i] = floor(2.0 * n / (1 << i));
  }
  L[6] = 0;
  ans = n;
  for (i1 = 1; i1 <= 6; ++i1)
    for (i2 = 1; i2 <= 6; ++i2)
      for (i3 = 1; i3 <= 6; ++i3) {
        A = max(sa - wa, L[i1]);
        B = max(sb - wb, L[i2]);
        C = max(sc - wc, L[i3]);
        if (A > sa || B > sb || C > sc || A > R[i1] || B > R[i2] || C > R[i3])
          continue;
        A = sa - A;
        B = sb - B;
        C = sc - C;
        me = get(a[1], b[1], c[1]) + (A + B + C) * 100;
        be = 0;
        f[0][0][0] = 0;
        for (int i = 2; i <= n; ++i) {
          if (get(a[i], b[i], c[i]) <= me) continue;
          ++be;
          for (p1 = 0; p1 < 2; ++p1)
            if (!p1 || a[i] < 0)
              for (p2 = 0; p2 < 2; ++p2)
                if (!p2 || b[i] < 0)
                  for (p3 = 0; p3 < 2; ++p3)
                    if (!p3 || c[i] < 0) {
                      if (get(p1 ? 250 : a[i], p2 ? 250 : b[i],
                              p3 ? 250 : c[i]) <= me) {
                        for (int x = p1; x <= A; ++x)
                          for (int y = p2; y <= B; ++y)
                            for (int z = p3; z <= C; ++z)
                              if (z - p3 > 1 && f[x - p1][y - p2][z - p3] == -1)
                                break;
                              else
                                g[x][y][z] = max(g[x][y][z],
                                                 f[x - p1][y - p2][z - p3] + 1);
                      }
                    }
          for (int x = 0; x <= A; ++x)
            for (int y = 0; y <= B; ++y)
              for (int z = 0; z <= C; ++z)
                if (z > 1 && g[x][y][z] == -1)
                  break;
                else
                  f[x][y][z] = max(g[x][y][z], f[x][y][z]), g[x][y][z] = -1;
        }
        tmp = 0;
        for (int x = 0; x <= A; ++x)
          for (int y = 0; y <= B; ++y)
            for (int z = 0; z <= C; ++z)
              if (z > 1 && f[x][y][z] == -1)
                break;
              else
                tmp = max(tmp, f[x][y][z]), f[x][y][z] = -1;
        ans = min(ans, be - tmp + 1);
      }
  printf("%d\n", ans);
  return 0;
}
