#include <bits/stdc++.h>
int n, x[1005], y[1005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &x[i], &y[i]);
  double L = x[1], R = x[2], w;
  if (y[3] > y[1]) L = x[2], R = x[1];
  for (int i = 3; i < n; i++) {
    if (y[i] == y[i + 1])
      w = 1e15 * ((x[i] < x[i + 1]) ^ (y[3] < y[1]) ? 1 : -1);
    else
      w = x[i] + 1. * (x[i] - x[i + 1]) / (y[i] - y[i + 1]) * (y[1] - y[i]);
    if ((y[i] < y[i + 1]))
      L = w > L ? w : L;
    else
      R = w < R ? w : R;
  }
  if (L > R + 1e-8)
    printf("0");
  else
    printf("%d\n", int(R + 1 + 1e-8) - int(L + 1 - 1e-8));
  return 0;
}
