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