#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,k,d[100],l,h, bd = 0,x,y,z,sum,kq;
string s;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
freopen("HINHVUONG.inp", "r", stdin);
freopen("HINHVUONG.out", "w", stdout);
cin >> n >> k;
kq=k;
for(int i=2;i<=n;++i)
{
sum=k;
x=i*i*(i-1)*(n+1)/2;
sum-=x;
y=i*i;
if(sum%y==0&&sum>0)
{
ll t = sum/y;
ll tam = t/n;
tam*=n;
t -= tam;
if(t + i - 1 <= n)
kq=min(kq,sum/y);
}
}
cout<<kq;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBsbCBsb25nIGxvbmcKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKbGwgbixrLGRbMTAwXSxsLGgsIGJkID0gMCx4LHkseixzdW0sa3E7CgpzdHJpbmcgczsKaW50IG1haW4oKQp7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOyBjaW4udGllKDApOyBjb3V0LnRpZSgwKTsKICAgIGZyZW9wZW4oIkhJTkhWVU9ORy5pbnAiLCAiciIsIHN0ZGluKTsKICAgIGZyZW9wZW4oIkhJTkhWVU9ORy5vdXQiLCAidyIsIHN0ZG91dCk7CiAgICBjaW4gPj4gbiA+PiBrOwogICAga3E9azsKICAgIGZvcihpbnQgaT0yO2k8PW47KytpKQogICAgewogICAgICAgIHN1bT1rOwogICAgICAgIHg9aSppKihpLTEpKihuKzEpLzI7CiAgICAgICAgc3VtLT14OwogICAgICAgIHk9aSppOwogICAgICAgIGlmKHN1bSV5PT0wJiZzdW0+MCkKICAgICAgICB7CiAgICAgICAgICAgIGxsIHQgPSBzdW0veTsKICAgICAgICAgICAgbGwgdGFtID0gdC9uOwogICAgICAgICAgICB0YW0qPW47CiAgICAgICAgICAgIHQgLT0gdGFtOwogICAgICAgICAgICBpZih0ICsgaSAtIDEgPD0gbikKICAgICAgICAgICAga3E9bWluKGtxLHN1bS95KTsKICAgICAgICB9CiAgICB9CiAgICBjb3V0PDxrcTsKfQo=