#include <bits/stdc++.h>   using namespace std;   int a, b, c, n;   int main() {     ios_base::sync_with_stdio(false);     ;     cin >> a >> b >> c >> n;     if (a - c < 0 || b - c < 0) return cout << -1, 0;     if (a + b - c >= n) return cout << -1, 0;     cout << n - (a + b - c);     return 0;   }   