#include <bits/stdc++.h>
using namespace std;
long long int a, s, d, f, g, h;
int main() {
  cin >> a >> s >> d >> f >> g;
  a = max(d, a);
  s = min(s, f);
  if (s < d || f < a)
    cout << 0;
  else if (a <= g && g <= s)
    cout << s - a;
  else
    cout << s - a + 1;
}
