#include <bits/stdc++.h>
using namespace std;
const int sco[7] = {0, 12, 10, 8, 6, 4, 2};
inline void update(int &x, int y) {
  if (x < y) x = y;
}
const int N = 5010;
int n, hack[3], score[N][3], wa[3], S[N];
int f[2][90][90][90];
pair<int, int> p[N][3];
bool canhack[N];
int main() {
  scanf("%d", &n);
  int lim[7] = {-1, n / 32, n / 16, n / 8, n / 4, n / 2, n};
  wa[0] = wa[1] = wa[2] = n;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 3; j++) {
      scanf("%d", &p[i][j].first);
      if (p[i][j].first == 0) wa[j]--;
      if (p[i][j].first < 0)
        p[i][j].second = 1, p[i][j].first *= -1, hack[j]++, canhack[i] = 1;
      if (p[i][j].first) p[i][j].first = 250 - p[i][j].first;
    }
  }
  if (hack[0] + hack[1] + hack[2] >= 90) {
    puts("1");
    return 0;
  }
  int ans = 0, cur = 0;
  for (int PA = 1; PA <= 6; PA++) {
    if (lim[PA - 1] < wa[0] && wa[0] - hack[0] <= lim[PA])
      for (int PB = 1; PB <= 6; PB++) {
        if (lim[PB - 1] < wa[1] && wa[1] - hack[1] <= lim[PB])
          for (int PC = 1; PC <= 6; PC++) {
            if (lim[PC - 1] < wa[2] && wa[2] - hack[2] <= lim[PC]) {
              int cannothack = 0;
              for (int i = 1; i <= n; i++) {
                S[i] = 0;
                score[i][0] = sco[PA] * p[i][0].first;
                score[i][1] = sco[PB] * p[i][1].first;
                score[i][2] = sco[PC] * p[i][2].first;
                for (int j = 0; j < 3; j++) S[i] += score[i][j];
              }
              int totscore = S[1];
              totscore += (min(wa[0] - lim[PA - 1] - 1, hack[0]) +
                           min(wa[1] - lim[PB - 1] - 1, hack[1]) +
                           min(wa[2] - lim[PC - 1] - 1, hack[2])) *
                          100;
              int sa = 0, sb = 0, sc = 0;
              f[cur][0][0][0] = 0;
              for (int i = 2; i <= n; i++) {
                if (!canhack[i]) {
                  cannothack += (S[i] <= totscore);
                  continue;
                }
                cur ^= 1;
                memset(f[cur], 0, sizeof(f[cur]));
                for (int j = 0; j <= sa; j++) {
                  for (int k = 0; k <= sb; k++) {
                    for (int l = 0; l <= sc; l++) {
                      for (int ha = 0; ha <= p[i][0].second; ha++) {
                        for (int hb = 0; hb <= p[i][1].second; hb++) {
                          for (int hc = 0; hc <= p[i][2].second; hc++) {
                            update(f[cur][j + ha][k + hb][l + hc],
                                   f[cur ^ 1][j][k][l] +
                                       ((S[i] - (ha ? score[i][0] : 0) -
                                         (hb ? score[i][1] : 0) -
                                         (hc ? score[i][2] : 0)) <= totscore));
                          }
                        }
                      }
                    }
                  }
                }
                sa += p[i][0].second;
                sb += p[i][1].second;
                sc += p[i][2].second;
              }
              ans = max(ans, cannothack +
                                 f[cur][min(wa[0] - lim[PA - 1] - 1, hack[0])]
                                  [min(wa[1] - lim[PB - 1] - 1, hack[1])]
                                  [min(wa[2] - lim[PC - 1] - 1, hack[2])]);
            }
          }
      }
  }
  printf("%d\n", n - ans);
  return 0;
}
