#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void ckmax(T& x, T y) {
  x = (y > x ? y : x);
}
template <typename T>
inline void ckmin(T& x, T y) {
  x = (y < x ? y : x);
}
const int MAXN = 5000;
const int score[6] = {500, 1000, 1500, 2000, 2500, 3000};
int n, a[MAXN + 5][3];
int can_hack[3], not_pass[3];
int st[3], l[3], r[3], rest[3], ord[3], s[8];
vector<int> vec[8];
bool vis[MAXN + 5];
int ans;
bool cmp_rest(int i, int j) { return rest[i] > rest[j]; }
void calc() {
  for (int i = 0; i < 3; ++i) {
    if (st[i] == 5) {
      l[i] = 0;
    } else {
      l[i] = n / (1 << (st[i] + 1)) + 1;
    }
    r[i] = n / (1 << st[i]);
    assert(l[i] <= r[i]);
    l[i] = n - l[i];
    r[i] = n - r[i];
    swap(l[i], r[i]);
    ckmax(l[i], not_pass[i]);
    ckmin(r[i], can_hack[i] + not_pass[i]);
    if (l[i] > r[i]) return;
  }
  int my_score = 0;
  for (int i = 0; i < 3; ++i) {
    rest[i] = r[i] - not_pass[i];
    my_score += 100 * rest[i];
    if (a[1][i] != 0) my_score += score[st[i]] / 250 * (250 - abs(a[1][i]));
  }
  for (int i = 0; i < (1 << 3); ++i) {
    vector<int>().swap(vec[i]);
  }
  for (int i = 1; i <= n; ++i) {
    vis[i] = 0;
  }
  for (int i = 2; i <= n; ++i) {
    for (int j = 0; j < (1 << 3); ++j) {
      bool wrong_status = 0;
      int sc = 0;
      for (int k = 0; k < 3; ++k) {
        if ((j >> k) & 1) {
          if (a[i][k] >= 0) {
            wrong_status = 1;
            break;
          }
        } else {
          if (a[i][k] != 0) sc += score[st[k]] / 250 * (250 - abs(a[i][k]));
        }
      }
      if (wrong_status) continue;
      if (sc > my_score) {
        continue;
      }
      vec[j].push_back(i);
    }
  }
  int cur_ans = n;
  while (1) {
    for (int i = 0; i < 3; ++i) ord[i] = i;
    sort(ord, ord + 3, cmp_rest);
    s[0] = 0;
    s[1] = (1 << ord[0]);
    s[2] = (1 << ord[1]);
    s[3] = ((1 << ord[0]) | (1 << ord[1]));
    s[4] = (1 << ord[2]);
    s[5] = ((1 << ord[0]) | (1 << ord[2]));
    s[6] = ((1 << ord[1]) | (1 << ord[2]));
    s[7] = ((1 << ord[0]) | (1 << ord[1]) | (1 << ord[2]));
    bool hack = 0;
    for (int i = 0; i <= 7; ++i) {
      int t = s[i];
      if (!((int)(vec[t]).size())) continue;
      if (vis[vec[t].back()]) {
        vec[t].pop_back();
        --i;
        continue;
      }
      bool fail = 0;
      for (int k = 0; k < 3; ++k) {
        if ((t >> k) & 1) {
          if (!rest[k]) {
            fail = 1;
            break;
          }
        }
      }
      if (fail) {
        continue;
      }
      for (int k = 0; k < 3; ++k) {
        if ((t >> k) & 1) {
          rest[k]--;
        }
      }
      cur_ans--;
      vis[vec[t].back()] = 1;
      vec[t].pop_back();
      hack = 1;
      break;
    }
    if (!hack) {
      break;
    }
  }
  ckmin(ans, cur_ans);
}
void dfs(int idx) {
  if (idx == 3) {
    calc();
    return;
  }
  for (int i = 0; i <= 5; ++i) {
    if (i == 5 || n / (1 << (i + 1)) + 1 <= n / (1 << i)) {
      st[idx] = i;
      dfs(idx + 1);
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i][0] >> a[i][1] >> a[i][2];
    for (int j = 0; j < 3; ++j) {
      can_hack[j] += (a[i][j] < 0);
      not_pass[j] += (a[i][j] == 0);
    }
  }
  ans = n;
  dfs(0);
  cout << ans << endl;
  return 0;
}
