#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll A[2], B[2];

int main()
{
  rep( i, 2 )
    std::cin >> A[i];
  rep( i, 2 )
    std::cin >> B[i];

  std::cout << std::min(A[0], A[1])+std::min(B[0], B[1]) << std::endl;

  return 0;
}
#include <cstdio>
using ll = long long;
inline ll gcd(ll x, ll y)
{
	while (y)
	{
		auto r = x % y;
		x = y;
		y = r;
	}
	return x;
}
inline bool chk(int n)
{
	for (int i = 2; i * i <= n; i++)
	{
		if (!(n % i))
			return false;
	}
	return true;
}
inline ll lcm(ll x, ll y) { return x && y ? x / gcd(x, y) * y : x + y; }
ll pri[1005], arr[505][505];
int main()
{
	// freopen("AGC027-D.in", "r", stdin);
	int n, cur = 0, len = 0;
	scanf("%d", &n);
	bool even = n & 1 ^ 1;
	n += even;
	for (int i = 2; len <= n * 2; i++)
	{
		if (chk(i))
			pri[len++] = i;
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
			arr[i][j] = 1;
	}
	for (int i = 0; i < n; i += 2, cur++)
	{
		int x = i, y = 0;
		while (x < n && y < n)
			arr[x++][y++] *= pri[cur];
	}
	for (int i = 2; i < n; i += 2, cur++)
	{
		int x = 0, y = i;
		while (x < n && y < n)
			arr[x++][y++] *= pri[cur];
	}
	cur = len - 1;
	for (int i = 0; i < n; i += 2, cur--)
	{
		int x = i, y = 0;
		while (x >= 0 && y < n)
			arr[x--][y++] *= pri[cur];
	}
	for (int i = 2; i < n; i += 2, cur--)
	{
		int x = n - 1, y = i;
		while (x >= 0 && y < n)
			arr[x--][y++] *= pri[cur];
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = i & 1 ^ 1; j < n; j += 2)
			arr[i][j] = lcm(lcm(i ? arr[i - 1][j] : 0, j ? arr[i][j - 1] : 0),
							lcm(arr[i + 1][j], arr[i][j + 1])) + 1;
	}
	n -= even;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
			printf("%lld%c", arr[i][j], " \n"[j + 1 == n]);
	}
	return 0;
}
