#include <bits/stdc++.h>
using namespace std;
int x1[110], yy1[110], x2[110], y2[110];
int v[110];
int main() {
  int n, i, j;
  double V, x, y;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d %d %d %d", &x1[i], &yy1[i], &x2[i], &y2[i]);
    if (x1[i] > x2[i]) swap(x1[i], x2[i]);
    if (yy1[i] > y2[i]) swap(yy1[i], y2[i]);
    v[i] = x2[i] - x1[i];
    v[i] *= v[i] * v[i];
  }
  for (i = 2; i <= n; i++) {
    V = 0;
    x = y = 0;
    for (j = i; j > 1; j--) {
      x = V * x + (double)v[j] * (x1[j] + x2[j]) / 2;
      y = V * y + (double)v[j] * (yy1[j] + y2[j]) / 2;
      V += v[j];
      x /= V;
      y /= V;
      if (x < x1[j - 1] - 1e-8 || x > x2[j - 1] + 1e-8 ||
          y < yy1[j - 1] - 1e-8 || y > y2[j - 1] + 1e-8)
        break;
    }
    if (j != 1) break;
  }
  printf("%d\n", i - 1);
  return 0;
}
