#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target( \
    "avx,avx2,fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long MOD = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),
      cout << fixed << setprecision(20);
  long long n;
  cin >> n;
  long long a[n], b[n], c[n];
  long long resh[3] = {0, 0, 0};
  long long vzl[3] = {0, 0, 0};
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
    resh[0] += a[i] != 0;
    vzl[0] += a[i] < 0;
    resh[1] += b[i] != 0;
    vzl[1] += b[i] < 0;
    resh[2] += c[i] != 0;
    vzl[2] += c[i] < 0;
    if (a[i] == 0) {
      a[i] = 250;
    }
    if (b[i] == 0) {
      b[i] = 250;
    }
    if (c[i] == 0) {
      c[i] = 250;
    }
  }
  if (vzl[0] + vzl[1] + vzl[2] > 90) {
    cout << 1;
    return 0;
  }
  long long ans = n + 1;
  for (int z1 = 0; z1 < 6; z1++) {
    for (int z2 = 0; z2 < 6; z2++) {
      for (int z3 = 0; z3 < 6; z3++) {
        long long ans_nw = 1;
        long long ball[6] = {2, 4, 6, 8, 10, 12};
        long long score = (250 - a[0]) * ball[z1] + (250 - b[0]) * ball[z2] +
                          (250 - c[0]) * ball[z3];
        long long mn1 = z1 == 5 ? 0 : (n >> (z1 + 1)) + 1;
        long long mn2 = z2 == 5 ? 0 : (n >> (z2 + 1)) + 1;
        long long mn3 = z3 == 5 ? 0 : (n >> (z3 + 1)) + 1;
        long long mx1 = (n >> z1);
        long long mx2 = (n >> z2);
        long long mx3 = (n >> z3);
        if (resh[0] >= mn1 && resh[0] - vzl[0] <= mx1) {
          if (resh[1] >= mn2 && resh[1] - vzl[1] <= mx2) {
            if (resh[2] >= mn3 && resh[2] - vzl[2] <= mx3) {
              long long vzl2[3] = {min(vzl[0], resh[0] - mn1),
                                   min(vzl[1], resh[1] - mn2),
                                   min(vzl[2], resh[2] - mn3)};
              score += (vzl2[0] + vzl2[1] + vzl2[2]) * 100;
              if (score > (ball[z1] + ball[z2] + ball[z3]) * 250) {
                cout << 1;
                return 0;
              }
              vector<pair<long long, long long> > ochk;
              for (int i = 0; i < n; i++) {
                if (a[i] > 0 && b[i] > 0 && c[i] > 0) {
                  long long sc2 = (250 - a[i]) * ball[z1] +
                                  (250 - b[i]) * ball[z2] +
                                  (250 - c[i]) * ball[z3];
                  if (sc2 > score) {
                    ans_nw++;
                  }
                } else {
                  long long sc2 = (250 - abs(a[i])) * ball[z1] +
                                  (250 - abs(b[i])) * ball[z2] +
                                  (250 - abs(c[i])) * ball[z3];
                  if (sc2 > score) ochk.push_back({sc2, i});
                }
              }
              sort(ochk.begin(), ochk.end());
              long long dp[ochk.size() + 1][vzl2[0] + 1][vzl2[1] + 1]
                          [vzl2[2] + 1];
              for (int nw = 0; nw <= ochk.size(); nw++) {
                for (int i = 0; i < vzl2[0] + 1; i++) {
                  for (int j = 0; j < vzl2[1] + 1; j++) {
                    for (int k = 0; k < vzl2[2] + 1; k++) {
                      dp[nw][i][j][k] = 0;
                    }
                  }
                }
              }
              for (int nw = 0; nw < ochk.size(); nw++) {
                for (int i = 0; i <= vzl2[0]; i++) {
                  for (int j = 0; j <= vzl2[1]; j++) {
                    for (int k = 0; k <= vzl2[2]; k++) {
                      for (int i1 = 0; i1 < min(2ll, vzl2[0] - i + 1); i1++) {
                        for (int i2 = 0; i2 < min(2ll, vzl2[1] - j + 1); i2++) {
                          for (int i3 = 0; i3 < min(2ll, vzl2[2] - k + 1);
                               i3++) {
                            long long sc1 =
                                (250 - abs(a[ochk[nw].second])) * ball[z1];
                            if (i1) {
                              if (a[ochk[nw].second] < 0) {
                                sc1 = 0;
                              } else {
                                continue;
                              }
                            }
                            long long sc2 =
                                (250 - abs(b[ochk[nw].second])) * ball[z2];
                            if (i2) {
                              if (b[ochk[nw].second] < 0) {
                                sc2 = 0;
                              } else {
                                continue;
                              }
                            }
                            long long sc3 =
                                (250 - abs(c[ochk[nw].second])) * ball[z3];
                            if (i3) {
                              if (c[ochk[nw].second] < 0) {
                                sc3 = 0;
                              } else {
                                continue;
                              }
                            }
                            if (sc1 + sc2 + sc3 <= score) {
                              dp[nw + 1][i + i1][j + i2][k + i3] =
                                  max(dp[nw + 1][i + i1][j + i2][k + i3],
                                      dp[nw][i][j][k] + 1);
                            } else {
                              dp[nw + 1][i + i1][j + i2][k + i3] =
                                  max(dp[nw + 1][i + i1][j + i2][k + i3],
                                      dp[nw][i][j][k]);
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
              ans_nw +=
                  ochk.size() - dp[ochk.size()][vzl2[0]][vzl2[1]][vzl2[2]];
              ans = min(ans_nw, ans);
            }
          }
        }
      }
    }
  }
  cout << ans;
}
