#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> a[5];
long long k;
int main() {
  for (long long i = 1, _b = (2); i <= _b; i++)
    cin >> a[i].first >> a[i].second;
  cin >> k;
  sort(a + 1, a + 2 + 1);
  if (a[1].second < a[2].first) return cout << 0, 0;
  long long res = min(a[2].second, a[1].second) - a[2].first + 1;
  if (k >= a[2].first && k <= min(a[1].second, a[2].second)) res--;
  cout << res;
}
