#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class WinterAndPresents { public:
	long long getNumber(vector <int> apple, vector <int> orange)
	{
		const int N = apple.size();
		int Xmax = 0x3fffffff;
		for(int i=0; i<N; ++i)
			Xmax = min(Xmax, apple[i]+orange[i]);

		LL total = 0;
		for(int X=1; X<=Xmax; ++X) {
			int am=0, aM=0;
			for(int i=0; i<N; ++i) {
				am += (X<=orange[i] ? 0 : X-orange[i]);
				aM += (X<=apple[i] ? X : apple[i]);
			}
			total += (aM-am+1);
		}
		return total;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const long long& Expected, const long long& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, WinterAndPresents().getNumber(apple, orange));}
int main(){

CASE(0)
	int apple_[] = {1};
	  vector <int> apple(apple_, apple_+sizeof(apple_)/sizeof(*apple_)); 
	int orange_[] = {1};
	  vector <int> orange(orange_, orange_+sizeof(orange_)/sizeof(*orange_)); 
	long long _ = 3LL; 
END
CASE(1)
	int apple_[] = {1, 2, 0, 3};
	  vector <int> apple(apple_, apple_+sizeof(apple_)/sizeof(*apple_)); 
	int orange_[] = {4, 5, 0, 6};
	  vector <int> orange(orange_, orange_+sizeof(orange_)/sizeof(*orange_)); 
	long long _ = 0LL; 
END
CASE(2)
	int apple_[] = {2, 2, 2};
	  vector <int> apple(apple_, apple_+sizeof(apple_)/sizeof(*apple_)); 
	int orange_[] = {2, 2, 2};
	  vector <int> orange(orange_, orange_+sizeof(orange_)/sizeof(*orange_)); 
	long long _ = 16LL; 
END
CASE(3)
	int apple_[] = {7, 4, 5};
	  vector <int> apple(apple_, apple_+sizeof(apple_)/sizeof(*apple_)); 
	int orange_[] = {1, 10, 2};
	  vector <int> orange(orange_, orange_+sizeof(orange_)/sizeof(*orange_)); 
	long long _ = 46LL; 
END
CASE(4)
	int apple_[] = {1000000};
	  vector <int> apple(apple_, apple_+sizeof(apple_)/sizeof(*apple_)); 
	int orange_[] = {1000000};
	  vector <int> orange(orange_, orange_+sizeof(orange_)/sizeof(*orange_)); 
	long long _ = 1000002000000LL; 
END
CASE(5)
	int apple_[] = {1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000};
	  vector <int> apple(apple_, apple_+sizeof(apple_)/sizeof(*apple_)); 
	int orange_[] = {1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000};
	  vector <int> orange(orange_, orange_+sizeof(orange_)/sizeof(*orange_)); 
	long long _ = -1LL; 
END
/*
CASE(6)
	int apple_[] = ;
	  vector <int> apple(apple_, apple_+sizeof(apple_)/sizeof(*apple_)); 
	int orange_[] = ;
	  vector <int> orange(orange_, orange_+sizeof(orange_)/sizeof(*orange_)); 
	long long _ = LL; 
END
*/
}
// END CUT HERE
