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