#include <bits/stdc++.h>
using namespace std;
const int N = 1000200;
long long int l1, r1, l2, r2, k;
int main() {
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  long long int val1 = max(l1, l2);
  long long int val2 = min(r1, r2);
  long long int ans = val2 - val1 + 1;
  long long int xx = 0;
  if (k >= val1 && k <= val2)
    cout << max(xx, (ans - 1)) << endl;
  else
    cout << max(xx, ans) << endl;
  return 0;
}
