#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int i, j, n, x[N], y[N], xx[N], yy[N];
bool check(int n) {
  long double sumx = 0, sumy = 0, sumM = 0;
  for (int i = n; i > 1; --i) {
    long double mass = abs(x[i] - xx[i]);
    mass *= mass * mass;
    sumx += mass * (x[i] + xx[i]) * 0.5;
    sumy += mass * (y[i] + yy[i]) * 0.5;
    sumM += mass;
    long double nx = sumx / sumM;
    long double ny = sumy / sumM;
    if (nx < min(x[i - 1], xx[i - 1]) || nx > max(x[i - 1], xx[i - 1]))
      return 0;
    if (ny < min(y[i - 1], yy[i - 1]) || ny > max(y[i - 1], yy[i - 1]))
      return 0;
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (i = 1; i <= n; ++i) cin >> x[i] >> y[i] >> xx[i] >> yy[i];
  for (i = 2; i <= n; ++i)
    if (!check(i)) return cout << i - 1 << '\n', 0;
  cout << n << '\n';
  return 0;
}
