#include "bits/stdc++.h" #ifndef MYDEBUG #define err(...) #define errs(...) #endif using namespace std; void Calc(); #define ALL(a) begin(a),end(a) #define RALL(a) (a).rbegin(),(a).rend() typedef int64_t ll; typedef uint64_t ull; signed main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cin.exceptions(istream::failbit | istream::badbit); Calc(); cout.flush(); return 0; } struct Scanner { templatestatic A Next() { A a; cin >> a; return a; } templatestatic vector Array(int n) { vector a(n); for (A& i : a) cin >> i; return a; } static string Line() { string s; getline(cin, s); return s; } static int Int() { return Next(); } templateScanner&operator,(A&a) { a = Next(); return *this; } templateoperator A() { return Next(); } }; Scanner in; /*---------------------------------------------------------------------*/ templatestruct NestV { typedef vector::t> t; static t C(int*it, T init) { return t(*it, NestV::C(it + 1, init)); } }; templatestruct NestV<0, T> { typedef T t; static T C(int*, T init) { return init; } }; templatetypename NestV::t DP(arraysize, T init = 0) { return NestV::C(&size[0], init); } /*---------------------------------------------------------------------*/ void Calc() { ll a, b; in, a, b; if (a < b) { cout << b - 2 << endl; } else { cout << 2000000000 - b - 1 << endl; } }