#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int l1, r1, l2, r2, g;
  scanf("%lld%lld%lld%lld%lld", &l1, &r1, &l2, &r2, &g);
  if (r1 < l2 || l1 > r2) {
    cout << "0" << endl;
    return 0;
  } else {
    long long int s = max(l1, l2);
    long long int n = min(r1, r2);
    long long int r = n - s + 1;
    if (s <= g && n >= g) r--;
    cout << r << endl;
  }
  return 0;
}
