#include using namespace std; int main(){ int a, b, c, d; cin >> a >> b >> c >> d; int64_t ans = 0; for(int i = a; i <= b; ++i){ if(i < c || i > d) ans += d - c + 1; else ans += d - c; } cout << ans << endl; }