#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
struct cube {
  int x1, y1, x2, y2;
};
cube a[110];
int main() {
  int n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i].x1 >> a[i].y1 >> a[i].x2 >> a[i].y2;
    if (a[i].x1 < a[i].x2) swap(a[i].x1, a[i].x2);
    if (a[i].y1 < a[i].y2) swap(a[i].y1, a[i].y2);
  }
  for (long long i = 2; i <= n; i++) {
    double x, y;
    long long m, m1;
    x = y = m = 0;
    for (long long j = i; j >= 2; j--) {
      m1 = (a[j].x1 - a[j].x2) * (a[j].x1 - a[j].x2) * (a[j].x1 - a[j].x2);
      x = double(
              (x * m + a[j].x2 * m1 + double((a[j].x1 - a[j].x2)) / 2 * m1)) /
          (m + m1);
      y = double(
              (y * m + a[j].y2 * m1 + double((a[j].y1 - a[j].y2)) / 2 * m1)) /
          (m + m1);
      m += m1;
      if (!(x >= a[j - 1].x2 && x <= a[j - 1].x1) ||
          !(y >= a[j - 1].y2 && y <= a[j - 1].y1)) {
        cout << i - 1 << endl;
        return 0;
      }
    }
  }
  cout << n << endl;
}
