#include using namespace std; typedef long long ll; #define int long long #define mk make_pair #define pb push_back #define pf push_front typedef pair pii; #define INF (1 << 30) #define INFL (1ll << 60ll); #define mod 1000000007 #define se second #define fi first int a, b, c, d; signed main() { cin >> a >> b >> c >> d; int ans = 0; for(int i = a; i <= b; i++){ if(c <= i && i <= d){ ans += d - c; } else { ans += d - c + 1; } } cout << ans << endl; return 0; } /* */