#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int MAXX = 112, i, j, k, x, y, xx, yy, n, ans, s, OFFSET = 55;
  cin >> n;
  vector<int> x1(n), y1(n), x2(n), y2(n);
  ans = 0;
  for (i = 0; i < n; i++) {
    cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
    x1[i] += OFFSET;
    x2[i] += OFFSET;
    y1[i] += OFFSET;
    y2[i] += OFFSET;
    if (x1[i] > x2[i]) swap(x1[i], x2[i]);
    if (y1[i] > y2[i]) swap(y1[i], y2[i]);
    if (i > 0) {
      vector<vector<int>> ct(MAXX, vector<int>(MAXX, 0));
      s = 0;
      for (j = i; j >= 1; j--) {
        for (x = x1[j]; x < x2[j]; x++) {
          for (y = y1[j]; y < y2[j]; y++) {
            ct[x][y] += x2[j] - x1[j];
            s += x2[j] - x1[j];
          }
        }
        long double sx = 0, sy = 0;
        for (x = 0; x < MAXX; x++) {
          for (y = 0; y < MAXX; y++) {
            sx += 1.0 * ct[x][y] * (x + 0.5);
            sy += 1.0 * ct[x][y] * (y + 0.5);
          }
        }
        sx /= s;
        sy /= s;
        bool valid = true;
        if ((sx < x1[j]) || (sx > x2[j]) || (sy < y1[j]) || (sy > y2[j]))
          valid = false;
        if ((sx < x1[j - 1]) || (sx > x2[j - 1]) || (sy < y1[j - 1]) ||
            (sy > y2[j - 1]))
          valid = false;
        if (!valid) goto outer;
      }
    }
    ans++;
  }
outer:;
  cout << ans << "\n";
  return 0;
}
