#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[6];
  for (int i = 0; i < 6; i++) cin >> a[i];
  a[5]++;
  int mn = 100000;
  for (int i = 0; i < 6; i++) {
    if (i == 4) continue;
    if (mn > a[i]) mn = a[i];
  }
  cout << (mn > a[4] ? mn - a[4] : 0) << endl;
  return 0;
}
