#include <iostream>
using namespace std;
int main() {
long long int a,b,c,d;
cin >> a; cin >> b; cin >> c; cin >> d;
long long int aS(0), bS(0);
for(long long int i = a; i<=b; ++i)
aS+=i;
for(long long int i = c; i<=d; ++i)
bS+=i;
cout << aS-bS;}
#include <iostream>
using namespace std;
int main() {
long long int a,b,c,d;
cin >> a; cin >> b; cin >> c; cin >> d;
long long int aS(0), bS(0);
for(long long int i = a; i<=b; ++i)
aS+=i;
for(long long int i = c; i<=d; ++i)
bS+=i;
cout << aS-bS;}