#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int n, i, t, s, flag;
long long x[N], y[N];
int main() {
  cin >> n;
  t = n;
  for (i = 1; i <= n; i++) cin >> x[i] >> y[i];
  if (y[n] > y[1])
    for (int i = (1); i <= (n); i++) y[i] = -y[i], x[i] = -x[i];
  for (i = x[1]; i <= x[2] && t > 2; i++)
    for (;
         (x[t] - i) * (y[t - 1] - y[1]) - (x[t - 1] - i) * (y[t] - y[1]) >= 0 &&
         t > 2;
         t--)
      ;
  s = i - 1;
  t = 2;
  for (i = x[2]; i >= x[1] && t < n; i--)
    for (;
         (x[t] - i) * (y[t + 1] - y[1]) - (x[t + 1] - i) * (y[t] - y[1]) <= 0 &&
         t < n;
         t++)
      ;
  i++;
  if (i - s + 1 > 0)
    cout << i - s + 1 << endl;
  else
    puts("0");
  return 0;
}
