#include using namespace std; #define rep(i,n) for(int i=0; i<(n); ++i) using ll = long long; int main(){ vector a(3); rep(i,3) cin >> a[i]; ll x = a[1] - a[0]; ll y = a[2] - a[1] - 1; cout << min(x,y) << endl; }