#include using namespace std; //#include //using namespace atcoder; using ll = long long int; using ull = unsigned long long int; using ld = long double; constexpr ll MAX = 2000000000000000000; constexpr ld PI = 3.14159265358979; constexpr ll MOD = 0;//2024948111; ld dotorad(ld K){ return PI * K / 180.0; } ld radtodo(ld K){ return K * 180.0 / PI; } mt19937 mt; void randinit(){ srand((unsigned)time(NULL));mt = mt19937(rand()); } int main(){ ll R,B; cin >> R >> B; if(R + B < 506){ for(ll n = 12;n >= 1;n--){ for(ll bit = 0;bit < (1LL << n);bit++){ ll a = 0,b = 0; for(ll i = 0;i < n;i++){ if(bit & (1LL << i)){ a += (i + 1) * (i + 1); } else{ b += (i + 1) * (i + 1); } } if(a <= R && b <= B){ cout << n << endl; return 0; } } } } ll a = 0; for(ll i = 1;i <= 1817121;i++){ if(a + i * i > R + B){ cout << i - 1 << endl; return 0; } a += i * i; } }