#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b, c; cin >> n >> a >> b >> c;
    while(c--)
    {
        a--, b--;
        n--;
    }
    cout << n - a - b << endl;
    return 0;
}


