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