#include <bits/stdc++.h>
using namespace std;
long long l1, l2, r1, r2, k;
int main() {
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  long long st = max(l1, l2);
  long long ed = min(r1, r2);
  long long res = ed - st + 1;
  if (k >= st && k <= ed) --res;
  if (res < 0) res = 0;
  cout << res;
  return 0;
}
