#include <bits/stdc++.h>
using namespace std;
const int N = 5000 + 1;
const int K = 90 + 1;
int place[2][K][K][K], when[N][3], type[3], weak[3], freq[3], hacks[3];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 0; i <= n - 1; ++i) {
    for (int j = 0; j <= 2; ++j) {
      cin >> when[i][j];
      weak[j] += (when[i][j] < 0);
      freq[j] += (when[i][j] != 0);
    }
  }
  if (weak[0] + weak[1] + weak[2] >= K) {
    cout << 1 << "\n";
    exit(0);
  }
  int m = 0;
  for (int i = 1; i <= n - 1; ++i) {
    if (*min_element(when[i], when[i] + 3) < 0) {
      if (i > ++m) {
        swap_ranges(when[i], when[i] + 3, when[m]);
      }
    }
  }
  int ans = INT_MAX;
  for (int a = 1; a <= 6; ++a) {
    for (int b = 1; b <= 6; ++b) {
      for (int c = 1; c <= 6; ++c) {
        type[0] = a, type[1] = b, type[2] = c;
        bool possible = true;
        for (int d = 0; d <= 2; ++d) {
          int low = (type[d] == 6) ? 0 : (n >> type[d]) + 1;
          if (low == (n >> (type[d] - 1)) + 1) {
            possible = false;
          } else {
            hacks[d] = freq[d] - low;
            if (hacks[d] < 0) {
              possible = false;
            } else if (hacks[d] > weak[d]) {
              if (freq[d] - weak[d] <= (n >> (type[d] - 1))) {
                hacks[d] = weak[d];
              } else {
                possible = false;
              }
            }
          }
        }
        if (!possible) {
          continue;
        }
        for (int d = 0; d <= hacks[0]; ++d) {
          for (int e = 0; e <= hacks[1]; ++e) {
            for (int f = 0; f <= hacks[2]; ++f) {
              place[0][d][e][f] = INT_MAX;
            }
          }
        }
        place[0][0][0][0] = 1;
        int me = 100 * accumulate(hacks, hacks + 3, 0);
        for (int d = 0; d <= 2; ++d) {
          if (when[0][d] > 0) {
            me += 2 * type[d] * (250 - when[0][d]);
          }
        }
        for (int d = 1; d <= m; ++d) {
          for (int e = 0; e <= hacks[0]; ++e) {
            for (int f = 0; f <= hacks[1]; ++f) {
              for (int g = 0; g <= hacks[2]; ++g) {
                place[d % 2][e][f][g] = INT_MAX;
              }
            }
          }
          for (int e = 0; e <= hacks[0]; ++e) {
            for (int f = 0; f <= hacks[1]; ++f) {
              for (int g = 0; g <= hacks[2]; ++g) {
                if (place[1 - d % 2][e][f][g] == INT_MAX) {
                  continue;
                }
                for (int h = 0; h <= (1 << 3) - 1; ++h) {
                  bool ok = true;
                  int him = 0;
                  for (int i = 0; i <= 2; ++i) {
                    if ((h & (1 << i)) == 0) {
                      if (when[d][i] != 0) {
                        him += 2 * type[i] * (250 - abs(when[d][i]));
                      }
                    } else if (when[d][i] >= 0) {
                      ok = false;
                    }
                  }
                  if (ok) {
                    int &p = place[d % 2][e + ((h & 1) > 0)][f + ((h & 2) > 0)]
                                  [g + ((h & 4) > 0)];
                    p = min(p, place[1 - d % 2][e][f][g] + (him > me));
                  }
                }
              }
            }
          }
        }
        int res = place[m % 2][hacks[0]][hacks[1]][hacks[2]];
        for (int d = m + 1; d <= n; ++d) {
          int him = 0;
          for (int e = 0; e <= 2; ++e) {
            if (when[d][e] > 0) {
              him += 2 * type[e] * (250 - when[d][e]);
            }
          }
          res += (him > me);
        }
        ans = min(ans, res);
      }
    }
  }
  cout << ans << "\n";
}
