#include<iostream>
#include<algorithm>
#include <vector>
#include<cmath>
#include<iomanip>
using namespace std;
typedef long long int lont;
int main() {
	int N, A, B, C;
	cin >> N >> A >> B >> C;
	cout << N - (A + B - C) << endl;
}
