#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l1, r1, l2, r2, k, count;
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  long long l, r;
  if (l1 > l2)
    l = l1;
  else
    l = l2;
  if (r1 < r2)
    r = r1;
  else
    r = r2;
  if (l > r)
    count = 0;
  else
    count = r - l + 1;
  if (k >= l && k <= r) count--;
  cout << count << endl;
}
