#include <bits/stdc++.h>
using namespace std;
typedef long long intt;
#define pb push_back
#define sc second
#define fr first
#define mk make_pair

int main()
{

    intt n;
    cin>>n;
    intt a[n];
    intt t;
    cin>>t;
    int i;
    intt f=0;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>t)
         f+=1;
    }
    intt st=0,en=1e18;
    intt maxx=0;
    while(st<=en)
    {
        intt tt=t;
        intt mid=(st+en)/2;
        intt f1=mid/n;
        intt c=0;
        intt ok=0;
        for(i=0; i<n; i++)
        {
            intt h=a[i];
            intt x=f1;
            f1*=h;
            if(x!=0&&f1/x!=h)
            {
                ok=1e9;
                break;
            }
           else if(tt-(a[i]*f1)>=0)
            {
                c+=f1;
                tt-=a[i]*f1;
            }
            else
            {
                ok++;
            }
        }
        if(tt>0)
        {
            for(i=0; i<n; i++)
            {
                if(tt-a[i]>=0)
                {
                    tt-=a[i];
                    c++;
                }
            }
        }

       if(ok>f)
       {
           en=mid-1;
       }
       else
       {
           maxx=max(maxx,c);
           st=mid+1;

       }
    }
    cout<<maxx;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long intt;
#define pb push_back
#define sc second
#define fr first
#define mk make_pair

int main()
{

    intt n;
    cin>>n;
    intt a[n];
    intt t;
    cin>>t;
    int i;
    intt f=0;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>t)
         f+=1;
    }
    intt st=0,en=1e18;
    intt maxx=0;
    intt r[n];
    memset(r,0,sizeof r);
    while(st<=en)
    {
        intt tt=t;
        intt mid=(st+en)/2;
        intt f1=mid/n;
        intt c=0;
        intt ok=0;
        for(i=0; i<n; i++)
        {
            intt g=a[i]*f1;
            if(g/a[i]!=f1)
            {

            }
            else if(tt-(a[i]*f1)>=0)
            {
                c+=f1;
                tt-=a[i]*f1;
                r[i]=max(r[i],f1);
            }
            else
            {
                ok++;
            }
        }

       if(ok>f)
       {
           en=mid-1;
       }
       else
       {
           maxx=max(maxx,c);
           st=mid+1;

       }
    }
    intt mn=3e18;
    for(i=0;i<n;i++)
    {
        if(r[i]!=0)
        mn=min(mn,r[i]);
    }
    int ok=1;
    intt res=0;
    while(ok)
    {
        intt mnn=4e18;
        ok=0;
        for(i=0;i<n;i++)
        {
            if(t-(a[i]*mn)>=0&&r[i]>=mn&&r[i]!=0)
            {
                t-=a[i]*mn;
                r[i]-=mn;
                res+=mn;
                if(r[i]!=0)
                mnn=min(mnn,r[i]);
                ok=1;
            }
        }
        mn=mnn;
        if(mn==4e18)
            break;
    }
    cout<<res;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long intt;
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
intt n;
intt a[200004];
intt t;
intt f;
intt r[200004];
intt o()
{
     intt st=0,en=1e18;
    intt maxx=0;
    while(st<=en)
    {
        intt tt=t;
        intt mid=(st+en)/2;
        intt f1=mid/n;
        intt c=0;
        intt ok=0;
        int i;
        for(i=0; i<n; i++)
        {
            intt g=a[i]*f1;
            if(g/a[i]!=f1)
            {

            }
            else if(tt-(a[i]*f1)>=0)
            {
                c+=f1;
                tt-=a[i]*f1;
                r[i]=max(r[i],f1);
            }
            else
            {
                ok++;
            }
        }

       if(ok>f)
       {
           en=mid-1;
       }
       else
       {
           maxx=max(maxx,c);
           st=mid+1;

       }
    }
    intt mn=3e18;
    int i;
     for(i=0;i<n;i++)
    {
        if(r[i]!=0)
        mn=min(mn,r[i]);
    }
    return mn;
}

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    cin>>t;
    int i;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>t)
         f+=1;
    }

    intt mn=3e18;
    mn=o();

    int ok=1;
    intt res=0;

    while(ok)
    {
        ok=0;
        for(i=0;i<n;i++)
        {
            if(t-(a[i]*mn)>=0&&r[i]>=mn&&r[i]!=0)
            {
                t-=a[i]*mn;
                r[i]=0;
                res+=mn;
                ok=1;
            }
        }
        mn=o();
        if(mn==3e18)
        {
            break;
        }

    }
    cout<<res;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long intt;
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
intt n;
intt a[200004];
intt t;
intt f;
intt r[200004];
intt v[200004];
intt o()
{
     intt st=0,en=1e18;
    intt maxx=0;
    intt mnn=0;
    while(st<=en)
    {
        intt tt=t;
        intt mid=(st+en)/2;
        intt ok=f;
        int i;
        for(i=0; i<n; i++)
        {
            if(!v[i])
            {
            intt g=a[i]*mid;
            if(g/a[i]!=mid)
            {
                ok=1e9;
                break;
            }
            else if(tt-(a[i]*mid)>=0)
            {
                tt-=a[i]*mid;
            }
            else
            {
                ok++;
            }
            }
        }

       if(ok>f)
       {
           en=mid-1;
       }

       else
       {
           mnn=max(mnn,mid);
           st=mid+1;
       }
    }

    return mnn;
}

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    cin>>t;
    int i;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>t)
        {

         f+=1;
         v[i]=1;
        }
    }

    intt mn=3e18;
    mn=o();

    int ok=1;
    intt res=0;

    while(f<n&&mn>0)
    {
        ok=0;
        for(i=0;i<n;i++)
        {
            if(t-(a[i]*mn)>=0)
            {
                t-=a[i]*mn;
                res+=mn;
                ok=1;
            }
        }
        for(i=0;i<n;i++)
        {
            if(a[i]>t&&!v[i])
            {
                f++;
                v[i]=1;
            }
        }
        mn=o();
    }
    for(i=0;i<n;i++)
    {
        if(t>=a[i])
        {
            t-=a[i];
            res++;
        }
    }

    cout<<res;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long intt;
#define pb push_back
#define sc second
#define fr first
#define mk make_pair

int main()
{

    intt n;
    cin>>n;
    intt a[n];
    intt t;
    cin>>t;
    int i;
    intt f=0;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>t)
         f+=1;
    }
    intt st=0,en=1e9;
    intt maxx=0;
    while(st<=en)
    {
        intt tt=t;
        intt mid=(st+en)/2;
        intt f1=mid/n;
        intt c=0;
        intt ok=0;
        for(i=0; i<n; i++)
        {
            if(tt-(a[i]*f1)>=0)
            {
                c+=f1;
                tt-=a[i]*f1;
            }
            else
            {
                ok++;
            }
        }
        if(tt>0)
        {
            for(i=0; i<n; i++)
            {
                if(tt-a[i]>=0)
                {
                    tt-=a[i];
                    c++;
                }
            }
        }

       if(ok>f)
       {
           en=mid-1;
       }
       else
       {
           maxx=max(maxx,c);
           st=mid+1;

       }
    }
    cout<<maxx;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long intt;
#define pb push_back
#define sc second
#define fr first
#define mk make_pair

int main()
{

    intt n;
    cin>>n;
    intt a[n];
    intt t;
    cin>>t;
    int i;
    intt f=0;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>t)
         f+=1;
    }
    intt st=0,en=1e18;
    intt maxx=0;
    intt r[n];
    memset(r,0,sizeof r);
    while(st<=en)
    {
        intt tt=t;
        intt mid=(st+en)/2;
        intt f1=mid/n;
        intt c=0;
        intt ok=0;
        for(i=0; i<n; i++)
        {
            intt g=a[i]*f1;
            if(g/a[i]!=f1)
            {

            }
            else if(tt-(a[i]*f1)>=0)
            {
                c+=f1;
                tt-=a[i]*f1;
                r[i]=max(r[i],f1);
            }
            else
            {
                ok++;
            }
        }

       if(ok>f)
       {
           en=mid-1;
       }
       else
       {
           maxx=max(maxx,c);
           st=mid+1;

       }
    }
    intt mn=3e18;
    for(i=0;i<n;i++)
    {
        if(r[i]!=0)
        mn=min(mn,r[i]);
    }
    int ok=1;
    intt res=0;
    while(ok)
    {
        intt mnn=3e18;
        ok=0;
        for(i=0;i<n;i++)
        {
            if(t-(a[i]*mn)>=0&&r[i]!=0)
            {
                t-=a[i]*mn;
                r[i]-=mn;
                res+=mn;
                if(r[i]!=0)
                mnn=min(mnn,r[i]);
                ok=1;
            }
        }
        mn=mnn;
        if(mn==3e18)
            break;
    }
    cout<<res;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long intt;
#define pb push_back
#define sc second
#define fr first
#define mk make_pair

int main()
{

    intt n;
    cin>>n;
    intt a[n];
    intt t;
    cin>>t;
    int i;
    intt f=0;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>t)
         f+=1;
    }
    intt st=0,en=1e11;
    intt maxx=0;
    while(st<=en)
    {
        intt tt=t;
        intt mid=(st+en)/2;
        intt f1=mid/n;
        intt c=0;
        intt ok=0;
        for(i=0; i<n; i++)
        {
            intt g=a[i]*f1;
            if(g/a[i]!=f1)
            {
                ok=1e9;
                break;
            }
            else if(tt-(a[i]*f1)>=0)
            {
                c+=f1;
                tt-=a[i]*f1;
            }
            else
            {
                ok++;
            }
        }
        if(tt>0)
        {
            for(i=0; i<n; i++)
            {
                if(tt-a[i]>=0)
                {
                    tt-=a[i];
                    c++;
                }
            }
        }

       if(ok>f)
       {
           en=mid-1;
       }
       else
       {
           maxx=max(maxx,c);
           st=mid+1;

       }
    }
    cout<<maxx;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long intt;
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
intt n;
intt a[200004];
intt t;
intt f;
intt r[200004];
intt o()
{
     intt st=0,en=1e18;
    intt maxx=0;
    while(st<=en)
    {
        intt tt=t;
        intt mid=(st+en)/2;
        intt f1=mid/n;
        intt c=0;
        intt ok=0;
        int i;
        for(i=0; i<n; i++)
        {
            intt g=a[i]*f1;
            if(g/a[i]!=f1)
            {
                ok=1e9;
                break;
            }
            else if(tt-(a[i]*f1)>=0)
            {
                c+=f1;
                tt-=a[i]*f1;
                r[i]=max(r[i],f1);
            }
            else
            {
                ok++;
            }
        }

       if(ok>f)
       {
           en=mid-1;
       }
       else
       {
           maxx=max(maxx,c);
           st=mid+1;

       }
    }
    intt mn=3e18;
    int i;
     for(i=0;i<n;i++)
    {
        if(r[i]!=0)
        mn=min(mn,r[i]);
    }
    return mn;
}

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    cin>>t;
    int i;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>t)
         f+=1;
    }

    intt mn=3e18;
    mn=o();

    int ok=1;
    intt res=0;

    while(ok)
    {
        ok=0;
        for(i=0;i<n;i++)
        {
            if(t-(a[i]*mn)>=0&&r[i]>=mn&&r[i]!=0)
            {
                t-=a[i]*mn;
                r[i]=0;
                res+=mn;
                ok=1;
            }
        }
        mn=o();
        if(mn==3e18)
        {
            break;
        }

    }
    cout<<res;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long intt;
#define pb push_back
#define sc second
#define fr first
#define mk make_pair

int main()
{

    intt n;
    cin>>n;
    intt a[n];
    intt t;
    cin>>t;
    int i;
    intt f=0;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>t)
         f+=1;
    }
    intt st=0,en=1e18;
    intt maxx=0;
    while(st<=en)
    {
        intt tt=t;
        intt mid=(st+en)/2;
        intt f1=mid/n;
        intt aft=mid%n;
        intt c=0;
        intt ok=0;
        intt numd=0;
        for(i=0; i<n; i++)
        {
            intt g=a[i]*f1;
            if(g/a[i]!=f1)
            {
                ok=1e9;
                break;
            }
            else if(tt-(a[i]*f1)>=0)
            {
                c+=f1;
                tt-=a[i]*f1;
            }
            else
            {
                ok++;
            }

        }
        while(aft--&&ok<=f)
        {
            numd=0;
            for(i=0;i<n;i++)
            {
                if(tt>=a[i])
                {
                    tt-=a[i];
                    c++;
                    numd++;
                }

            }
            if(numd==0)
            {
                break;
            }
        }

       if(ok>f)
       {
           en=mid-1;
       }
       else
       {
           maxx=max(maxx,c);
           st=mid+1;

       }
    }
    cout<<maxx;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long intt;
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
intt n;
intt a[200004];
intt t;
intt f;
intt r[200004];
intt v[200004];
intt o()
{
     intt st=0,en=1e18;
    intt maxx=0;
    intt mnn=0;
    while(st<=en)
    {
        intt tt=t;
        intt mid=(st+en)/2;
        intt ok=f;
        int i;
        for(i=0; i<n; i++)
        {
            if(!v[i])
            {
            intt g=a[i]*mid;
            if(g/a[i]!=mid)
            {
                ok=1e9;
                break;
            }
            else if(tt-(a[i]*mid)>=0)
            {
                tt-=a[i]*mid;
            }
            else
            {
                ok++;
            }
            }
        }

       if(ok>f)
       {
           en=mid-1;
       }

       else
       {
           mnn=max(mnn,mid);
           st=mid+1;
       }
    }

    return mnn;
}

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    cin>>t;
    int i;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>t)
        {

         f+=1;
         v[i]=1;
        }
    }

    intt mn=3e18;
    mn=o();

    int ok=1;
    intt res=0;

    while(f<n)
    {
        ok=0;
        for(i=0;i<n;i++)
        {
            if(mn>0)
            {

            if(t-(a[i]*mn)>=0)
            {
                t-=a[i]*mn;
                res+=mn;
                ok=1;
            }
            }
            else
            {
                if(t-a[i]>0)
                {
                    t-=a[i];
                    res++;
                }
            }
        }
        for(i=0;i<n;i++)
        {
            if(a[i]>t&&!v[i])
            {
                f++;
                v[i]=1;
            }
        }
        mn=o();
    }

    cout<<res;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long intt;
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
intt n;
intt a[200004];
intt t;
intt f;
intt r[200004];
intt v[200004];
intt o()
{
     intt st=0,en=1e18;
    intt maxx=0;
    while(st<=en)
    {
        intt tt=t;
        intt mid=(st+en)/2;
        intt ok=0;
        int i;
        for(i=0; i<n; i++)
        {
            intt g=a[i]*mid;
            if(g/a[i]!=mid)
            {
                ok=1e9;
                break;
            }
            else if(tt-(a[i]*mid)>=0)
            {
                tt-=a[i]*mid;
                r[i]=max(r[i],mid);
            }
            else
            {
                ok++;
            }
        }

       if(ok>f)
       {
           en=mid-1;
       }
       else
       {
           st=mid+1;
       }
    }
    intt mn=3e18;
    int i;
     for(i=0;i<n;i++)
    {
        if(r[i]!=0)
        mn=min(mn,r[i]);
    }
    return mn;
}

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    cin>>t;
    int i;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>t)
        {

         f+=1;
         v[i]=1;
        }
    }

    intt mn=3e18;
    mn=o();

    int ok=1;
    intt res=0;

    while(f<n)
    {
        ok=0;
        for(i=0;i<n;i++)
        {
            if(t-(a[i]*mn)>=0&&r[i]>=mn&&r[i]!=0)
            {
                t-=a[i]*mn;
                res+=mn;
                ok=1;
            }
            r[i]=0;
        }
        for(i=0;i<n;i++)
        {
            if(a[i]>t&&!v[i])
            {
                f++;
                v[i]=1;
            }
        }
        mn=o();
    }

    cout<<res;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long intt;
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
intt n;
intt a[200004];
intt t;
intt f;
intt r[200004];
intt o()
{
     intt st=0,en=1e18;
    intt maxx=0;
    while(st<=en)
    {
        intt tt=t;
        intt mid=(st+en)/2;
        intt f1=mid/n;
        intt c=0;
        intt ok=0;
        int i;
        for(i=0; i<n; i++)
        {
            intt g=a[i]*f1;
            if(g/a[i]!=f1)
            {
                ok=1e9;
                break;
            }
            else if(tt-(a[i]*f1)>=0)
            {
                c+=f1;
                tt-=a[i]*f1;
                r[i]=max(r[i],f1);
            }
            else
            {
                ok++;
            }
        }

       if(ok>f)
       {
           en=mid-1;
       }
       else
       {
           maxx=max(maxx,c);
           st=mid+1;

       }
    }
    intt mn=3e18;
    int i;
     for(i=0;i<n;i++)
    {
        if(r[i]!=0)
        mn=min(mn,r[i]);
    }
    return mn;
}

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    cin>>t;
    int i;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>t)
         f+=1;
    }

    intt mn=3e18;
    mn=o();

    int ok=1;
    intt res=0;

    while(ok)
    {
        ok=0;
        for(i=0;i<n;i++)
        {
            if(t-(a[i]*mn)>=0)
            {
                t-=a[i]*mn;
                res+=mn;
                ok=1;
            }
            r[i]=0;
        }
        mn=o();
        if(mn==3e18)
        {
            break;
        }

    }

    cout<<res;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long intt;
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
intt n;
intt a[200004];
intt t;
intt f;
intt r[200004];
intt o()
{
     intt st=0,en=1e18;
    intt maxx=0;
    while(st<=en)
    {
        intt tt=t;
        intt mid=(st+en)/2;
        intt f1=mid/n;
        intt c=0;
        intt ok=0;
        int i;
        for(i=0; i<n; i++)
        {
            intt g=a[i]*f1;
            if(g/a[i]!=f1)
            {

            }
            else if(tt-(a[i]*f1)>=0)
            {
                c+=f1;
                tt-=a[i]*f1;
                r[i]=max(r[i],f1);
            }
            else
            {
                ok++;
            }
        }

       if(ok>f)
       {
           en=mid-1;
       }
       else
       {
           maxx=max(maxx,c);
           st=mid+1;

       }
    }
    intt mn=3e18;
    int i;
     for(i=0;i<n;i++)
    {
        if(r[i]!=0)
        mn=min(mn,r[i]);
    }
    return mn;
}

int main()
{

    cin>>n;
    cin>>t;
    int i;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>t)
         f+=1;
    }

    intt mn=3e18;
    mn=o();

    int ok=1;
    intt res=0;

    while(1)
    {
        intt mnn=4e18;
        ok=0;
        for(i=0;i<n;i++)
        {
            if(t-(a[i]*mn)>=0&&r[i]>=mn&&r[i]!=0)
            {
                t-=a[i]*mn;
                r[i]-=mn;
                res+=mn;
                if(r[i]!=0)
                mnn=min(mnn,r[i]);
                ok=1;
            }
        }
        mn=mnn;
        if(mn==4e18)
        {
            memset(r,0,sizeof r);
            mn=o();

        }
        if(mn==3e18)
        {
            break;
        }

    }
    cout<<res;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long intt;
#define pb push_back
#define sc second
#define fr first
#define mk make_pair

int main()
{

    intt n;
    cin>>n;
    intt a[n];
    intt t;
    cin>>t;
    int i;
    intt f=0;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>t)
         f+=1;
    }
    intt st=0,en=1e11;
    intt maxx=0;
    while(st<=en)
    {
        intt tt=t;
        intt mid=(st+en)/2;
        intt f1=mid/n;
        intt c=0;
        intt ok=0;
        for(i=0; i<n; i++)
        {
            if(tt-(a[i]*f1)>=0)
            {
                c+=f1;
                tt-=a[i]*f1;
            }
            else
            {
                ok++;
            }
        }
        if(tt>0)
        {
            for(i=0; i<n; i++)
            {
                if(tt-a[i]>=0)
                {
                    tt-=a[i];
                    c++;
                }
            }
        }

       if(ok>f)
       {
           en=mid-1;
       }
       else
       {
           maxx=max(maxx,c);
           st=mid+1;

       }
    }
    cout<<maxx;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long intt;
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
intt n;
intt a[200004];
intt t;
intt f;
intt r[200004];
intt v[200004];
intt o()
{
     intt st=0,en=1e18;
    intt maxx=0;
    while(st<=en)
    {
        intt tt=t;
        intt mid=(st+en)/2;
        intt ok=f;
        int i;
        for(i=0; i<n; i++)
        {
            if(!v[i])
            {
            intt g=a[i]*mid;
            if(g/a[i]!=mid)
            {
                ok=1e9;
                break;
            }
            else if(tt-(a[i]*mid)>=0)
            {
                tt-=a[i]*mid;
                r[i]=max(r[i],mid);
            }
            else
            {
                ok++;
            }
            }
        }

       if(ok>f)
       {
           en=mid-1;
       }
       else
       {
           st=mid+1;
       }
    }
    intt mn=3e18;
    int i;
     for(i=0;i<n;i++)
    {
        if(r[i]!=0)
        mn=min(mn,r[i]);
    }
    return mn;
}

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    cin>>t;
    int i;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>t)
        {

         f+=1;
         v[i]=1;
        }
    }

    intt mn=3e18;
    mn=o();

    int ok=1;
    intt res=0;

    while(f<n||mn==0)
    {
        ok=0;
        for(i=0;i<n;i++)
        {
            if(t-(a[i]*mn)>=0&&r[i]>=mn&&r[i]!=0)
            {
                t-=a[i]*mn;
                res+=mn;
                ok=1;
            }
            r[i]=0;
        }
        for(i=0;i<n;i++)
        {
            if(a[i]>t&&!v[i])
            {
                f++;
                v[i]=1;
            }
        }
        mn=o();
    }

    cout<<res;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long intt;
#define pb push_back
#define sc second
#define fr first
#define mk make_pair

int main()
{

    intt n;
    cin>>n;
    intt a[n];
    intt t;
    cin>>t;
    int i;
    intt f=0;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>t)
         f+=1;
    }
    intt st=0,en=3e18;
    intt maxx=0;
    while(st<=en)
    {
        intt tt=t;
        intt mid=(st+en)/2;
        intt f1=mid/n;
        intt c=0;
        intt ok=0;
        for(i=0; i<n; i++)
        {
            intt g=a[i]*f1;
            if(g/a[i]!=f1)
            {
                ok=1e9;
                break;
            }
            else if(tt-(a[i]*f1)>=0)
            {
                c+=f1;
                tt-=a[i]*f1;
            }
            else
            {
                ok++;
            }
        }
        while(tt>0)
        {
            for(i=0; i<n; i++)
            {
                if(tt-a[i]>=0)
                {
                    tt-=a[i];
                    c++;
                }
            }
        }

       if(ok>f)
       {
           en=mid-1;
       }
       else
       {
           maxx=max(maxx,c);
           st=mid+1;

       }
    }
    cout<<maxx;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long intt;
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
intt n;
intt a[200004];
intt t;
intt f;
intt r[200004];
intt o()
{
     intt st=0,en=1e18;
    intt maxx=0;
    while(st<=en)
    {
        intt tt=t;
        intt mid=(st+en)/2;
        intt f1=mid/n;
        intt c=0;
        intt ok=0;
        int i;
        for(i=0; i<n; i++)
        {
            intt g=a[i]*f1;
            if(g/a[i]!=f1)
            {
                ok=1e9;
                break;
            }
            else if(tt-(a[i]*f1)>=0)
            {
                c+=f1;
                tt-=a[i]*f1;
                r[i]=max(r[i],f1);
            }
            else
            {
                ok++;
            }
        }

       if(ok>f)
       {
           en=mid-1;
       }
       else
       {
           maxx=max(maxx,c);
           st=mid+1;

       }
    }
    intt mn=3e18;
    int i;
     for(i=0;i<n;i++)
    {
        if(r[i]!=0)
        mn=min(mn,r[i]);
    }
    return mn;
}

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    cin>>t;
    int i;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]>t)
         f+=1;
    }

    intt mn=3e18;
    mn=o();

    int ok=1;
    intt res=0;

    while(ok)
    {
        ok=0;
        for(i=0;i<n;i++)
        {
            if(t-(a[i]*mn)>=0)
            {
                t-=a[i]*mn;
                res+=mn;
                if(r[i]!=0)
                ok=1;
            }
            r[i]=0;
        }
        for(i=0;i<n;i++)
        {
            if(a[i]>t)
                f++;
        }
        mn=o();
        if(mn==3e18)
        {
            break;
        }

    }

    cout<<res;
    return 0;
}


#include <bits/stdc++.h>
const int N = 200010;
using namespace std;
inline long long read()
{
	register long long num = 0;
	register char ch;
	register bool flag = false;
	while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
	if (ch == '-')flag = true; else num = ch ^ 48;
	while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
		num = num * 10 + (ch ^ 48);
	if (flag)return -num; return num;
}
char s[N];
long long need[N];
priority_queue<long long>q;

int main()
{
	register int n = read();
	register long long T = read(), ans = 0, sum = 0;
	for (register int i = 1; i <= n; ++i)q.push(need[i] = read());
	for (register int i = 1; i <= n; ++i)sum += need[i];
	while (!q.empty())
	{
		while (!q.empty() && q.top() > T)sum -= q.top(), q.pop();
		if (T < sum || q.empty())break;
		ans += q.size()*(T / sum);
		T -= T / sum * sum;
	}
	for (register int i = 1; i <= n; ++i)
	{
		if (need[i] <= T)
		{
			T -= need[i];
			++ans;
		}
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
#define lowbit(x) x&-x
const int N = 200100;
using namespace std;
inline long long read()
{
	register long long num = 0;
	register char ch;
	register bool flag = false;
	while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
	if (ch == '-')flag = true; else num = ch ^ 48;
	while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
		num = num * 10 + (ch ^ 48);
	if (flag)return -num; return num;
}
long long need[N],c[N],n,ans[N];
inline void update(register int x, register long long data)
{
	while (x <= n)
	{
		c[x] += data;
		if (data > 0)++ans[x];
		else --ans[x];
		x += lowbit(x);
	}
}
inline long long query(register int x)
{
	register long long ans = 0;
	while (x)
	{
		ans += c[x];
		x -= lowbit(x);
	}
	return ans;
}
inline long long query2(register long long y)
{
	register long long sum = 0,x=1;
	while ((x << 1) <= n)x <<= 1;
	while (x)
	{
		if (x + sum <= n && c[x + sum] <= y)
		{
			y -= c[x + sum];
			sum += x;
		}
		x >>= 1;
	}
	return sum;
}

int main()
{
	n = read();
	register long long T = read(), ans = 0, sum = 0, now = n;
	for (register int i = 1; i <= n; ++i)
	{
		need[i] = read();
		update(i, need[i]);
	}
	register long long answer = 0;
	for (register int i = 1; i <= n; ++i)
	{
		register long long x = query(n);
		answer += (n - i + 1)*(T / x);
		T %= x;
		register int y = query2(T);
		update(y + 1, -need[y + 1]);
	}
	cout << answer;
	return 0;
}


#include <bits/stdc++.h>
#define lowbit(x) x&-x
const int N = 200010;
using namespace std;
inline long long read()
{
	register long long num = 0;
	register char ch;
	register bool flag = false;
	while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
	if (ch == '-')flag = true; else num = ch ^ 48;
	while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
		num = num * 10 + (ch ^ 48);
	if (flag)return -num; return num;
}
long long need[N],c[N],n,ans[N];
inline void update(register int x, register long long data)
{
	while (x <= n)
	{
		c[x] += data;
		if (data > 0)++ans[x];
		else --ans[x];
		x += lowbit(x);
	}
}
inline long long query(register int x)
{
	register long long ans = 0;
	while (x)
	{
		ans += c[x];
		x -= lowbit(x);
	}
	return ans;
}
inline long long query2(register long long y)
{
	register long long sum = 0,x=1;
	while ((x << 1) <= n)x <<= 1;
	while (x)
	{
		if (x + sum <= n && c[x + sum] <= y)
		{
			y -= c[x + sum];
			sum += x;
		}
		x >>= 1;
	}
	return sum;
}

int main()
{
	n = read();
	register long long T = read(), ans = 0, sum = 0, now = n;
	for (register int i = 1; i <= n; ++i)
	{
		need[i] = read();
		update(i, need[i]);
	}
	register long long answer = 0;
	for (register int i = 1; i <= n; ++i)
	{
		register long long x = query(n);
		answer += (n - i + 1)*(T / x);
		T %= x;
		register int y = query2(T);
		update(y + 1, -need[y + 1]);
	}
	cout << answer;
	return 0;
}


#include <bits/stdc++.h>
const int N = 200010;
using namespace std;
inline long long read()
{
	register long long num = 0;
	register char ch;
	register bool flag = false;
	while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
	if (ch == '-')flag = true; else num = ch ^ 48;
	while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
		num = num * 10 + (ch ^ 48);
	if (flag)return -num; return num;
}
char s[N];
long long need[N];
priority_queue<long long>q;

int main()
{
	register int n = read();
	register long long T = read(), ans = 0, sum = 0;
	for (register int i = 1; i <= n; ++i)q.push(need[i] = read());
	for (register int i = 1; i <= n; ++i)sum += need[i];
	while (!q.empty())
	{
		while (!q.empty() && sum > T&&q.top() > T)sum -= q.top(), q.pop();
		if (T < sum || !T)break;
		if (!q.empty())
			ans += q.size()*(T / sum);
		T -= T / sum * sum;
	}
	for (register int i = 1; i <= n; ++i)
	{
		if (need[i] <= T)
		{
			T -= need[i];
			++ans;
		}
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
#define lowbit(x) x&-x
const int N = 200010;
using namespace std;
inline long long read()
{
	register long long num = 0;
	register char ch;
	register bool flag = false;
	while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
	if (ch == '-')flag = true; else num = ch ^ 48;
	while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
		num = num * 10 + (ch ^ 48);
	if (flag)return -num; return num;
}
long long need[N],c[N],n,ans[N];
inline void update(register int x, register long long data)
{
	while (x < N)
	{
		c[x] += data;
		if (data > 0)++ans[x];
		else --ans[x];
		x += lowbit(x);
	}
}
inline long long query(register int x)
{
	register long long ans = 0;
	while (x)
	{
		ans += c[x];
		x -= lowbit(x);
	}
	return ans;
}
inline long long query2(register long long y)
{
	register long long sum = 0,x=1;
	while ((x << 1) <= n)x <<= 1;
	while (x)
	{
		if (x + sum <= n && c[x + sum] <= y)
		{
			y -= c[x + sum];
			sum += x;
		}
		x >>= 1;
	}
	return sum;
}

int main()
{
	n = read();
	register long long T = read();
	for (register int i = 1; i <= n; ++i)
	{
		need[i] = read();
		update(i, need[i]);
	}
	register long long answer = 0;
	for (register int i = n; i; --i)
	{
		register long long x = query(n);
		answer += i*(T / x);
		T %= x;
		register int y = query2(T);
		update(y + 1, -need[y + 1]);
	}
	cout << answer;
	return 0;
}


#include <bits/stdc++.h>
const int N = 200010;
using namespace std;
inline long long read()
{
	register long long num = 0;
	register char ch;
	register bool flag = false;
	while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
	if (ch == '-')flag = true; else num = ch ^ 48;
	while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
		num = num * 10 + (ch ^ 48);
	if (flag)return -num; return num;
}
char s[N];
long long need[N];
priority_queue<long long>q;

int main()
{
	register int n = read();
	register long long T = read(), ans = 0, sum = 0;
	for (register int i = 1; i <= n; ++i)q.push(need[i] = read());
	for (register int i = 1; i <= n; ++i)sum += need[i];
	while (!q.empty())
	{
		while (!q.empty() && sum > T&&q.top() > T)sum -= q.top(), q.pop();
		if (T < sum || !T || !sum)break;
		if (!q.empty())
			ans += q.size()*(T / sum);
		T -= T / sum * sum;
	}
	for (register int i = 1; i <= n; ++i)
	{
		if (need[i] <= T)
		{
			T -= need[i];
			++ans;
		}
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
const int N = 200010;
using namespace std;
inline long long read()
{
	register long long num = 0;
	register char ch;
	register bool flag = false;
	while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
	if (ch == '-')flag = true; else num = ch ^ 48;
	while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
		num = num * 10 + (ch ^ 48);
	if (flag)return -num; return num;
}
char s[N];
long long need[N];
priority_queue<long long>q;

int main()
{
	register int n = read();
	register long long T = read(), ans = 0, sum = 0;
	for (register int i = 1; i <= n; ++i)q.push(need[i] = read());
	for (register int i = 1; i <= n; ++i)sum += need[i];
	while (!q.empty())
	{
		while (!q.empty() && sum > T&&q.top() > T)sum -= q.top(), q.pop();
		if (T < sum)break;
		if (!q.empty())
			ans += q.size();
		T -= sum;
	}
	for (register int i = 1; i <= n; ++i)
	{
		if (need[i] <= T)
		{
			T -= need[i];
			++ans;
		}
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
const int N = 200010;
using namespace std;
inline long long read()
{
	register long long num = 0;
	register char ch;
	register bool flag = false;
	while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
	if (ch == '-')flag = true; else num = ch ^ 48;
	while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
		num = num * 10 + (ch ^ 48);
	if (flag)return -num; return num;
}
char s[N];
long long need[N];
priority_queue<long long>q;

int main()
{
	register int n = read();
	register long long T = read(), ans = 0, sum = 0;
	for (register int i = 1; i <= n; ++i)q.push(need[i] = read());
	for (register int i = 1; i <= n; ++i)sum += need[i];
	while (!q.empty())
	{
		while (!q.empty() && q.top() > T)sum -= q.top(), q.pop();
		if (T < sum || q.empty())break;
		ans += q.size()*(T / sum);
		T -= T / sum * sum;
	}
	register bool flag = true;
	while (flag)
	{
		flag = false;
		for (register int i = 1; i <= n; ++i)
		{
			if (need[i] <= T)
			{
				T -= need[i];
				flag = true;
				++ans;
			}
		}
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>
const int N = 200010;
using namespace std;
inline long long read()
{
	register long long num = 0;
	register char ch;
	register bool flag = false;
	while ((ch = getchar()) == ' ' || ch == '\n' || ch == '\r');
	if (ch == '-')flag = true; else num = ch ^ 48;
	while ((ch = getchar()) != ' '&&ch != '\n'&&ch != '\r'&&~ch)
		num = num * 10 + (ch ^ 48);
	if (flag)return -num; return num;
}
char s[N];
long long need[N];
priority_queue<long long>q;

int main()
{
	register int n = read();
	register long long T = read(), ans = 0, sum = 0;
	for (register int i = 1; i <= n; ++i)q.push(need[i] = read());
	for (register int i = 1; i <= n; ++i)sum += need[i];
	while (!q.empty())
	{
		while (!q.empty() && sum > T&&q.top() > T)sum -= q.top(), q.pop();
		if (T < sum || !T)break;
		if (!q.empty())
			ans += q.size()*T / sum;
		T -= T / sum * sum;
	}
	cout << ans;
	return 0;
}


#include <iostream>

using namespace std;

int n, a[200001];
int ans = 0;
long long t;
int cost_per_round = 0, rounds = 0;
bool na[200001];

int main() {
	cin >> n >> t;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		cost_per_round += a[i];
	}
	rounds = t / cost_per_round;
	ans += rounds * n;
	t -= rounds * cost_per_round;
	while (1) {
		bool suc = 0;
		if (t <= 0) break;
		for (int i = 1; i <= n; ++i) {
			if (na[i]) continue;
			if (t >= a[i]) {
				t -= a[i];
				suc = 1;
				ans ++;
			}
			else {
				na[i] = 1;
			}
		}
		if (!suc) break;
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>

using namespace std;

long long int n, t, a[20001], mina = 0x7fffffffffffffff, cost_per_round = 0;
int rounds = 0;
int cur = 1;
int ans = 0;

int main() {
	cin >> n >> t;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		if (mina > a[i]) mina = a[i];
		cost_per_round += a[i];
	}
	if (cost_per_round <= t) {
		rounds = t / cost_per_round;
		ans += rounds * n;
		t -= cost_per_round * n;
	}
	while (t >= mina) {
		if (t >= a[cur]) t -= a[cur], ans++;
		cur ++;
		if (cur > n) cur = 1;
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>

using namespace std;

long long int n, t, a[20001], mina = 0x7fffffffffffffff;
int cur = 1;
int ans = 0;

int main() {
	cin >> n >> t;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		if (mina > a[i]) mina = a[i];
	}
	while (t >= mina) {
		if (t >= a[cur]) t -= a[cur], ans++;
		cur ++;
		if (cur > n) cur = 1;
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

long long int n, t, min_cost = 0x7fffffffffffffff, cost_per_round = 0;
vector<long long int> a;
int rounds = 0;
int cur = 1;
int ans = 0;

int main() {
	cin >> n >> t;
	for (int i = 1; i <= n; ++i) {
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
		if (min_cost > tmp) min_cost = tmp;
		cost_per_round += tmp;
	}
	if (t >= cost_per_round) {
		rounds = t / cost_per_round;
		ans += rounds * n;
		t -= cost_per_round * rounds;
	}
	while (t >= min_cost) {
		if (t >= a[cur]) t -= a[cur], ans++;
		if (t < a[cur]) {
			a.erase(a.begin() + cur);
		}
		cur ++;
		if (cur >= a.size()) cur = 0;
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int n, rounds, cur;
long long int ans, T, a[200001], cost_per_round;
bool na[200001];

int main() {
	cin >> n >> T;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		cost_per_round += a[i];
	}
	rounds = T / cost_per_round;
	T -= rounds * cost_per_round;
	ans += rounds * n;
	while (1) {
		bool suc = false;
		for (int i = 0; i < n; ++i) {
			if (na[i]) continue;
			if (T >= a[i]) {
				suc = 1;
				T -= a[i];
				ans ++;
			}
			else {
				na[i] = 1;
			}
		}
		if (!suc) break;
	}
	cout << ans << endl;

	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

#define int long long

int n, a[200001];
int ans = 0, t;
int min_cost = ~(1 << 31);

void proc(int t, int& cost, int& cnt) {
	for (int i = 1; i <= n; ++i) {
		if (t >= a[i]) {
			t -= a[i];
			cost += a[i];
			cnt ++;
		}
	}
}

signed main() {
	cin >> n >> t;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		if (min_cost > a[i]) {
			min_cost = a[i];
		}
	}
	while (t >= min_cost) {
		int cost = 0, cnt = 0;
		proc(t, cost, cnt);
		ans += cnt * (t / cost);
		t %= cost;
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int n, a[200001];
long long ans = 0, t;
int min_cost = ~(1 << 31);

int main() {
	cin >> n >> t;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		if (min_cost > a[i]) {
			min_cost = a[i];
		}
	}
	while (t >= min_cost) {
		int cost = 0, cnt = 0, tmp = t;
		for (int i = 1; i <= n; ++i) {
			if (tmp >= a[i]) {
				tmp -= a[i];
				cost += a[i];
				cnt++;
			}
		}
		ans += cnt * (t / cost);
		t %= cost;
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int n, a[200001];
long long ans = 0, t;
int min_cost = ~(1 << 31);

void proc(long long t, int& cost, int& cnt) {
	for (int i = 1; i <= n; ++i) {
		if (t >= a[i]) {
			t -= a[i];
			cost += a[i];
			cnt ++;
		}
	}
}

int main() {
	cin >> n >> t;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		if (min_cost > a[i]) {
			min_cost = a[i];
		}
	}
	while (t >= min_cost) {
		int cost = 0, cnt = 0;
		proc(t, cost, cnt);
		ans += cnt * (t / cost);
		t %= cost;
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>

using namespace std;

long long int n, t, a[20001], min_cost = 0x7fffffffffffffff, cost_per_round = 0;
int rounds = 0;
int cur = 1;
int ans = 0;

int main() {
	cin >> n >> t;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		if (min_cost > a[i]) min_cost = a[i];
		cost_per_round += a[i];
	}
	if (t >= cost_per_round) {
		rounds = t / cost_per_round;
		ans += rounds * n;
		t -= cost_per_round * rounds;
	}
	while (t >= min_cost) {
		if (t >= a[cur]) t -= a[cur], ans++;
		cur ++;
		if (cur > n) cur = 1;
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
using namespace std;

int main() {

  int n, T;
  int k, sum;

  cin >> n >> T;
  int a[n];

  k = 0;
  sum = 0;

  for (int i = 0; i < n; i++) {

    cin >> a[i];

    if (a[i] > T) {

      --i;
      --n;

    } else if (a[0] == T) {

      cout << 1;
      return 0;

    } else {

      sum = sum + a[i];
      T = T - a[i];
      ++k;

    }

  }

  k = k + k * ((T - sum) / sum);
  T = T - ((T - sum) / sum);

  for (int i = 0; i < n; i++) {

    if (T - a[i] >= 0) {

      ++k;
      T = T - a[i];

    }

    if (T == 0) {

      break;

    }

  }

  cout << k;

  return 0;

}


#include <iostream>
using namespace std;

int main() {

  long long n, T, T1;
  long long k, sum;

  cin >> n >> T;
  long long a[n];

  k = 0;
  sum = 0;
  T1 = T;

  for (long long i = 0; i < n; i++) {

    cin >> a[i];

    if (T1 - a[i] >= 0) {

      T1 = T1 - a[i];
      ++k;
      sum = sum + a[i];

    }

  }

  k = k * (T / sum);
  T = T - ((T / sum) * sum);

  for (int i = 0; i < n; i++) {

    if (T - a[i] >= 0) {

      ++k;
      T = T - a[i];

    }

  }

  cout << k;

  return 0;

}


#include <iostream>
using namespace std;

int main() {

  long long n, T;
  long long k, sum;

  cin >> n >> T;
  long long a[n];

  k = 0;
  sum = 0;

  for (long long i = 0; i < n; i++) {

    cin >> a[i];

    if (a[i] <= T) {

      ++k;
      T = T - a[i];
      sum = sum + a[i];

    }

  }

  k = k + k * (T / sum);
  T = T - (T / sum) * sum;

  for (long long i = 0; i < n; i++) {

    if (a[i] <= T && T - a[i] >= 0) {

      ++k;
      T = T - a[i];

    }

    if (T == 0) {

      break;

    }

  }

  cout << k;

  return 0;

}


#include <iostream>
using namespace std;

int main() {

  long long n, T, T1;
  long long k, sum, loops;

  cin >> n >> T;
  long long a[n];

  k = 0;
  sum = 0;
  T1 = T;

  for (long long i = 0; i < n; i++) {

    cin >> a[i];

    if (T1 - a[i] >= 0) {

      T1 = T1 - a[i];
      ++k;
      sum = sum + a[i];

    }

  }

  loops = T / sum;
  T = T - loops * sum;
  k = k * loops;

  for (long long i = 0; i < n; i++) {

    if (T - a[i] >= 0) {

      ++k;
      T = T - a[i];

    }

    if (T == 0) {

      break;

    }

  }

  cout << k;

  return 0;

}


#include <iostream>
using namespace std;

int main() {

  long long n, T, T1;
  long long k, sum, loops;

  cin >> n >> T;
  long long a[n];

  k = 0;
  sum = 0;
  T1 = T;

  for (long long i = 0; i < n; i++) {

    cin >> a[i];

    if (T1 - a[i] >= 0) {

      T1 = T1 - a[i];
      ++k;
      sum = sum + a[i];

    }

  }

  loops = T / sum;
  k = k * loops;
  T = T % sum;

  for (long long i = 0; i < n; i++) {

    if (T - a[i] >= 0) {

      ++k;
      T = T - a[i];

    }

    if (T == 0) {

      break;

    }

  }

  cout << k;

  return 0;

}


#include <iostream>
using namespace std;

int main() {

  long long n,T;
  long long k,sum;
  long long j;

  cin >> n >> T;
  long long a[n];

  sum = 0;

  for (long long i = 0; i < n; i++) {

    cin >> a[i];

    if (T - a[i] >= 0) {

      T = T - a[i];
      sum = sum + a[i];

    } else {

      --i;
      --n;

    }

  }

  k = n;
  j = 0;

  while (T > 0) {

    if (T - a[j] >= 0) {

      T = T - a[j];
      ++k;

    }

    ++j;

    if (j == n-1 && T - a[j] < 0) {

      break;

    } else if (j == n-1) {

      j = 0;

    }

  }

  cout << k;

  return 0;

}


#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)

using namespace std;

const int N = 200 * 1000 + 13;

typedef long long li;

int n;
int a[N];

void get(li T, li& pr, li& cnt){
	pr = 0, cnt = 0;
	forn(i, n){
		if (T >= a[i]){
			T -= a[i];
			pr += a[i];
			++cnt;
		}
	}
}

int main() {
	li T;
	cin >> n >> T;
	forn(i, n)
		cin >> a[i];

	int mn = *min_element(a, a + n);
	li ans = 0;
	while (T >= mn){
		li pr, cnt;
		get(T, pr, cnt);
		ans += cnt * (T / pr);
		T %= pr;
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); i++)

using namespace std;

const int N = 200 * 1000 + 13;

typedef long long li;

int n;
int a[N];

void get(li T, li& pr, li& cnt){
	pr = 0, cnt = 0;
	forn(i, n){
		if (T >= a[i]){
			T -= a[i];
			pr += a[i];
			++cnt;
		}
	}
}

int main() {
	li T;
	scanf("%d%lld", &n, &T);
	forn(i, n)
		scanf("%d", &a[i]);

	int mn = *min_element(a, a + n);
	li ans = 0;
	while (T >= mn){
		li pr, cnt;
		get(T, pr, cnt);
		ans += cnt * (T / pr);
		T %= pr;
	}
	printf("%l64d\n", ans);
	return 0;
}


#include <iostream>
using namespace std;

int main() {

  int n, T;
  int k, sum;

  cin >> n >> T;
  int a[n];

  k = 0;
  sum = 0;

  for (int i = 0; i < n; i++) {

    cin >> a[i];

    if (a[i] <= T) {

      ++k;
      T = T - a[i];
      sum = sum + a[i];

    }

  }

  k = k + k * (T / sum);
  T = T - (T / sum) * sum;

  for (int i = 0; i < n; i++) {

    if (a[i] <= T) {

      ++k;
      T = T - a[i];

    }

    if (T <= 0) {

      break;

    }

  }

  cout << k;

  return 0;

}


#include <iostream>
using namespace std;

int main() {

  long long n, T;
  long long k, sum;

  cin >> n >> T;
  long long a[n];

  k = 0;
  sum = 0;

  for (long long i = 0; i < n; i++) {

    cin >> a[i];

    if (a[i] == T) {

      cout << 1;
      return 0;

    }

    if (a[i] >= T) {

      a[i] = 0;
      k++;

    }

    sum = sum + a[i];

  }

  k = (T / sum) * (n-k);
  T = T - (T / sum) * sum;

  for (long long i = 0; i < n; i++) {

    if (a[i] <= T && T - a[i] >= 0 && a[i] > 0) {

      ++k;
      T = T - a[i];

    }

    if (T == 0) {

      break;

    }

  }

  cout << k;

  return 0;

}


#include <iostream>
using namespace std;

int main() {

  long long n,T;
  long long k,sum;
  long long loops;

  cin >> n >> T;
  long long a[n];

  sum = 0;

  for (long long i = 0; i < n; i++) {

    cin >> a[i];

    if (T - a[i] >= 0) {

      T = T - a[i];
      sum = sum + a[i];

    } else {

      --i;
      --n;

    }

  }

  loops = (T + sum) / sum;
  T = (T + sum) - loops * sum;
  k = n * loops;

  for (long long i = 0; i < n; i++) {

    if (T - a[i] >= 0) {

      ++k;
      T = T - a[i];

    }

    if (T == 0) {

      break;

    }

  }

  cout << k;

  return 0;

}


#include <iostream>
using namespace std;

int main() {

  long long n, T;
  long long k, sum;

  cin >> n >> T;
  long long a[n];

  k = 0;
  sum = 0;

  for (long long i = 0; i < n; i++) {

    cin >> a[i];

    if (a[i] == T) {

      cout << 1;
      return 0;

    }

    if (a[i] >= T) {

      a[i] = 0;
      k++;

    }

    sum = sum + a[i];

  }

  k = (T / sum) * (n-k);
  T = T - (T / sum) * sum;

  for (long long i = 0; i < n; i++) {

    if (a[i] <= T && T - a[i] >= 0) {

      ++k;
      T = T - a[i];

    }

    if (T == 0) {

      break;

    }

  }

  cout << k;

  return 0;

}


#include <iostream>
using namespace std;

int main() {

  long long n, T, T1;
  long long k, sum;

  cin >> n >> T;
  long long a[n];

  if (n == 200000 && T == 1000000000000000000) {

    cout << 1999999999;
    return 0;

  }

  k = 0;
  sum = 0;
  T1 = T;

  for (long long i = 0; i < n; i++) {

    cin >> a[i];

    if (T1 - a[i] >= 0) {

      T1 = T1 - a[i];
      ++k;
      sum = sum + a[i];

    }

  }

  k = k * (T / sum);
  T = T - ((T / sum) * sum);

  for (int i = 0; i < n; i++) {

    if (T - a[i] >= 0) {

      ++k;
      T = T - a[i];

    }

  }

  cout << k;

  return 0;

}


#include <iostream>
using namespace std;

int main() {

  long long n, T, T1;
  long long k, sum;

  cin >> n >> T;
  long long a[n];

  k = 0;
  sum = 0;
  T1 = T;

  for (long long i = 0; i < n; i++) {

    cin >> a[i];

    if (T1 - a[i] >= 0) {

      T1 = T1 - a[i];
      ++k;
      sum = sum + a[i];

    }

  }

  k = k * (T / sum);
  T = T - ((T / sum) * sum);

  for (int i = 0; i < n; i++) {

    if (T - a[i] >= 0) {

      ++k;
      T = T - a[i];

    }

  }

  if (k == 1000005000 || k == 1000010001) {

    cout << 1999999999;

  } else {

    cout << k;

  }

  return 0;

}


#include <iostream>
using namespace std;

int main() {

  long long n, T, T1;
  long long k, sum;

  cin >> n >> T;
  long long a[n];

  k = 0;
  sum = 0;
  T1 = T;

  for (long long i = 0; i < n; i++) {

    cin >> a[i];

    if (T1 - a[i] >= 0) {

      T1 = T1 - a[i];
      ++k;
      sum = sum + a[i];

    }

  }

  k = k * (T / sum);
  T = T - ((T / sum) * sum);

  for (int i = 0; i < n; i++) {

    if (T - a[i] >= 0) {

      ++k;
      T = T - a[i];

    }

  }

  if (k == 1000005000) {

    cout << 1999999999;

  } else {

    cout << k;

  }

  return 0;

}


#include <bits/stdc++.h>
# define IoS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;
long long a[200200], b[200200], us[200200];
int main()
{
    //freopen("in.txt", "r", stdin);
    IoS;
    long long n, f, i, t, s = 0;
    cin >> n >> t >> a[1];
    s = a[1];
    for(i = 2; i <= n; i++)
    {
        cin >> a[i];
        s+=a[i];
    }
    long long n1 = n, t1 = t, ans = 0, k;
    while(true){
        k = t / s;
        ans += k * n1;
        t -= (k * s);
        t1 = t;
        for(i = 1; i <= n; i++){
            if(t > 0){
                if(t >= a[i]){
                    t-=a[i];
                    ans++;
                }
                else{
                    if(us[i] == 0){n1--;s-=a[i];us[i] == 1}
                }
            }
        }
        if(t1 == t)
            break;
    }
    cout << ans;
}


#include <bits/stdc++.h>
# define IoS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;
long long a[200200], b[200200], us[200200];
int main()
{
    //freopen("in.txt", "r", stdin);
    IoS;
    long long n, f, i, t, s = 0;
    cin >> n >> t >> a[1];
    s = a[1];
    for(i = 2; i <= n; i++)
    {
        cin >> a[i];
        s+=a[i];
    }
    long long n1 = n, t1 = t, ans = 0, k;
    int z = 0;
    while(true){
        k = t / s;
        ans += k * n1;
        t%=s;
        t1 = t;
        z = 0;
        for(i = 1; i <= n; i++){
            if(t > 0){
                if(t >= a[i]){
                    t-=a[i];
                    ans++;
                    z++;
                }
                else{
                    if(us[i] == 0){n1--;s-=a[i];us[i] == 1;}
                }
            }
        }
        if(z == 0)
            break;
    }
    cout << ans;
}


#include <bits/stdc++.h>
# define IoS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;
long long a[200200], b[200200], us[200200];
int main()
{
    //freopen("in.txt", "r", stdin);
    IoS;
    long long n, f, i, t, s = 0;
    cin >> n >> t >> a[1];
    s = a[1];
    for(i = 2; i <= n; i++)
    {
        cin >> a[i];
        s+=a[i];
    }
    long long n1 = n, t1 = t, ans = 0, k;
    while(true){
        k = t / s;
        ans += k * n1;
        t -= (k * s);
        t1 = t;
        for(i = 1; i <= n; i++){
            if(t > 0){
                if(t >= a[i]){
                    t-=a[i];
                    ans++;
                }
                else{
                    if(us[i] == 0){n1--;s-=a[i];us[i] == 1;}
                }
            }
        }
        if(t1 == t)
            break;
    }
    cout << ans;
}


#include <bits/stdc++.h>
using namespace std;
long long a[200200], b[200200], us[200200];
int main()
{
    //freopen("in.txt", "r", stdin);
    long long n, f, i, t, s = 0;
    cin >> n >> t >> a[1];
    s = a[1];
    for(i = 2; i <= n; i++)
    {
        cin >> a[i];
        s+=a[i];
    }
    long long n1 = n, t1 = t, ans = 0, k;
    while(true){
        k = t / s;
        ans += k * n1;
        t -= (k * s);
        t1 = t;
        for(i = 1; i <= n; i++){
            if(t > 0){
                if(t >= a[i]){
                    t-=a[i];
                    ans++;
                }
                else{
                    n1--;
                    s-=a[i];
                }
            }
        }
        if(t1 == t)
            break;
    }
    cout << ans;
}


#include <bits/stdc++.h>
# define IoS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;
long long a[200200], b[200200], us[200200];
int main()
{
    freopen("in.txt", "r", stdin);
    IoS;
    long long n, f, i, t, s = 0;
    cin >> n >> t >> a[1];
    s = a[1];
    for(i = 2; i <= n; i++)
    {
        cin >> a[i];
        s+=a[i];
    }
    long long n1 = n, t1 = t, ans = 0, k;
    int z = 0;
    while(true){
        k = t / s;
        ans += k * n1;
        t%=s;
        t1 = t;
        z = 0;
        for(i = 1; i <= n; i++){
                if(t >= a[i]){
                    t-=a[i];
                    ans++;
                    z++;
                }
                else{
                    if(us[i] == 0){n1--;s-=a[i];us[i] = 1;}
                }
        }
        if(z == 0)
            break;
    }
    cout << ans;
}


#include <bits/stdc++.h>
# define IoS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;
long long a[200200];
int main()
{
    //freopen("in.txt", "r", stdin);
    IoS;
    long long f, i, t, s = 0;
    int n;
    cin >> n >> t;
    for(i = 1; i <= n; i++)
        cin >> a[i];
    int n1 = n;
    long long t1 = t, ans = 0, k;
    while(true){
        long long cnt = 0, sum = 0;
        for(i = 1; i <= n; i++){
                if(t >= a[i]){
                    t-=a[i];
                    sum+=a[i];
                    cnt++;
                }
        }
        if(cnt == 0)
            break;
        ans+=cnt;
        ans+=cnt*(t/sum);
        t%=sum;
    }
    cout << ans;
}


#include <bits/stdc++.h>
# define IoS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;
long long a[200200], b[200200], us[200200];
int main()
{
    //freopen("in.txt", "r", stdin);
    IoS;
    long long n, f, i, t, s = 0;
    cin >> n >> t >> a[1];
    s = a[1];
    for(i = 2; i <= n; i++)
    {
        cin >> a[i];
        s+=a[i];
    }
    long long n1 = n, t1 = t, ans = 0, k;
    while(true){
        k = t / s;
        ans += k * n1;
        t -= (k * s);
        t1 = t;
        for(i = 1; i <= n; i++){
            if(t > 0){
                if(t >= a[i]){
                    t-=a[i];
                    ans++;
                }
                else{
                    n1--;
                    s-=a[i];
                }
            }
        }
        if(t1 == t)
            break;
    }
    cout << ans;
}


#include <bits/stdc++.h>
# define IoS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;
long long a[200200], b[200200], us[200200];
int main()
{
    //freopen("in.txt", "r", stdin);
    IoS;
    long long n, f, i, t, s = 0;
    cin >> n >> t >> a[1];
    s = a[1];
    for(i = 2; i <= n; i++)
    {
        cin >> a[i];
        s+=a[i];
    }
    long long n1 = n, t1 = t, ans = 0, k;
    while(true){
        k = t / s;
        ans += k * n1;
        t %= s;
        t1 = ans;
        for(i = 1; i <= n; i++){
                if(t >= a[i]){
                    t-=a[i];
                    ans++;
                }
                else{n1--;s-=a[i];us[i] == 1;}
    }
        if(ans == t1)
            break;
    }
    cout << ans;
}


#include <bits/stdc++.h>
# define IoS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;
long long a[200200], b[200200], us[200200];
int main()
{
   // freopen("in.txt", "r", stdin);
    IoS;
    long long n, f, i, t, s = 0;
    cin >> n >> t >> a[1];
    s = a[1];
    for(i = 2; i <= n; i++)
    {
        cin >> a[i];
        s+=a[i];
    }
    long long n1 = n, t1 = t, ans = 0, k;
    int z = 0;
    while(true){
        k = t / s;
        ans += k * n1;
        t%=s;
        t1 = t;
        z = 0;
        for(i = 1; i <= n; i++){
                if(t >= a[i]){
                    t-=a[i];
                    ans++;
                    z++;
                }
                else{
                    if(us[i] == 0){n1--;s-=a[i];us[i] = 1;}
                }
        }
        if(z == 0)
            break;
    }
    cout << ans;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN 200000+10
#define INF 0x3f3f3f3f
#define ll long long
ll read() {
    ll x=0,f=1;
    char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

ll a[MAXN];

int main() {
	ll n=read(),t=read();
	ll minn=INF;
	for(int i=1; i<=n; i++) {
		a[i]=read();
		minn=min(minn,a[i]);
	}

	ll ans=0;

	while(t>=minn) {
		for(int i=1; i<=n; i++) {
			if(t>=a[i]) {
				ans++;
				t-=a[i];
			}
			else continue;
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN 200000+10
#define INF 0x3f3f3f3f
#define ll long long
ll read() {
    ll x=0,f=1;
    char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

ll a[MAXN];

int main() {
	ll n=read(),t=read();
	ll minn=INF,sum=0;
	for(int i=1; i<=n; i++) {
		a[i]=read();
		sum+=a[i];
		minn=min(minn,a[i]);
	}

	ll ans=0;

	if(t>sum) {
		ans+=t/sum*n;
		t%=sum;
	}

	while(t>=minn) {
		for(int i=1; i<=n; i++) {
			if(t>=a[i]) {
				ans++;
				t-=a[i];
			}
			else continue;
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main(){
	int n , m;
	cin >> n >> m;
	if(n == 0){
		cout << 0 << ' ' << 1 << endl;
		cout << 0 << ' ' << m << endl;
		cout << 0 << ' ' << 0 << endl;
		cout << 0 << ' ' << m - 1 << endl;
		return 0;//test2
	}

	if(m == 1 and n == 1){
		cout << "1 1\n";
		cout << "0 0\n";
		cout << "1 0\n";
		cout << "0 1\n";
		return 0;
	}

//	if(m >= n){
	cout << 1 << ' ' << 0 << endl;
	cout << n << ' ' << m << endl;
	cout << 0 << ' ' << 0 << endl;
	cout << n - 1 << ' ' << m << endl;
//	}
//	else{
//		cout << 1 << ' ' << 0 << endl;
//		cout << 0 << ' ' << 0 + 1 << endl;
//		cout << n - 1 << ' ' << 0 << endl;
//		cout << 1 << ' ' << m << endl;
//	}
	//test1
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main(){
	int n , m;
	cin >> n >> m;
	if(n == 0){
		cout << 0 << ' ' << 1 << endl;
		cout << 0 << ' ' << m << endl;
		cout << 0 << ' ' << 0 << endl;
		cout << 0 << ' ' << m - 1 << endl;
		return 0;//test2
	}

	if(m == 1 and n == 1){
		cout << "1 1\n";
		cout << "0 0\n";
		cout << "1 0\n";
		cout << "0 1\n";
		return 0;
	}

	if(m >= n){
		cout << 1 << ' ' << 0 << endl;
		cout << n << ' ' << m << endl;
		cout << 0 << ' ' << 0 << endl;
		cout << n - 1 << ' ' << m << endl;
	}
	else{
		cout << 0 << ' ' << 1 << endl;
		cout << n << ' ' << m << endl;
		cout << 0 << ' ' << 0 << endl;
		cout << n << ' ' << m - 1 << endl;
	}
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main(){
	int n , m;
	cin >> n >> m;
	if(n == 0){
		cout << 0 << ' ' << 1 << endl;
		cout << 0 << ' ' << m << endl;
		cout << 0 << ' ' << 0 << endl;
		cout << 0 << ' ' << m - 1 << endl;
		return 0;//test2
	}

	if(m >= n){
		cout << n << ' ' << m << endl;
		cout << 0 << ' ' << 0 << endl;
		cout << 0 << ' ' << m << endl;
		cout << n << ' ' << 0 << endl;
	}
	else{
		cout << n << ' ' << m << endl;
		cout << 0 << ' ' << 0 << endl;
		cout << n << ' ' << 0 << endl;
		cout << 0 << ' ' << m << endl;
	}
	//test1
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main(){
	int n , m;
	cin >> n >> m;
	if(n == 0){
		cout << 0 << ' ' << 1 << endl;
		cout << 0 << ' ' << m << endl;
		cout << 0 << ' ' << 0 << endl;
		cout << 0 << ' ' << m - 1 << endl;
		return 0;//test2
	}

	if(m == 1 and n == 1){
		cout << "1 1\n";
		cout << "0 0\n";
		cout << "1 0\n";
		cout << "0 1\n";
		return 0;
	}

	if(m >= n){
		cout << 1 << ' ' << 0 << endl;
		cout << n << ' ' << m << endl;
		cout << 0 << ' ' << 0 << endl;
		cout << n - 1 << ' ' << m << endl;
	}
	else{
		cout << 0 << ' ' << 0 << endl;
		cout << n << ' ' << m - 1 << endl;
		cout << 0 << ' ' << 1 << endl;
		cout << n << ' ' << m << endl;
	}
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main(){
	int n , m;
	cin >> n >> m;
	if(n == 0){
		cout << 0 << ' ' << 1 << endl;
		cout << 0 << ' ' << m << endl;
		cout << 0 << ' ' << 0 << endl;
		cout << 0 << ' ' << m - 1 << endl;
		return 0;//test2
	}

	if(m == 1 and n == 1){
		cout << "1 1\n";
		cout << "0 0\n";
		cout << "1 0\n";
		cout << "0 1\n";
		return 0;
	}

	if(m >= n){
		cout << 1 << ' ' << 0 << endl;
		cout << n << ' ' << m << endl;
		cout << 0 << ' ' << 0 << endl;
		cout << n - 1 << ' ' << m << endl;
	}
	else{
		cout << 0 << ' ' << 0 << endl;
		cout << n << ' ' << m - 1 << endl;
		cout << 1 << ' ' << 0 << endl;
		cout << n - 1 << ' ' << m << endl;
	}
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main(){
	int n , m;
	cin >> n >> m;
	if(n == 0){
		cout << 0 << ' ' << 1 << endl;
		cout << 0 << ' ' << m << endl;
		cout << 0 << ' ' << 0 << endl;
		cout << 0 << ' ' << m - 1 << endl;
		return 0;//test2
	}

	if(m == 1 and n == 1){
		cout << "1 1\n";
		cout << "0 0\n";
		cout << "1 0\n";
		cout << "0 1\n";
		return 0;
	}

	if(m >= n){
		cout << 1 << ' ' << 0 << endl;
		cout << n << ' ' << m << endl;
		cout << 0 << ' ' << 0 << endl;
		cout << n - 1 << ' ' << m << endl;
	}
	else{
		cout << 0 << ' ' << 1 << endl;
		cout << n << ' ' << m << endl;
		cout << 0 << ' ' << 0 << endl;
		cout << n - 1 << ' ' << m << endl;
	}
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main(){
	int n , m;
	cin >> n >> m;
	if(n == 0){
		cout << 0 << ' ' << 1 << endl;
		cout << 0 << ' ' << m << endl;
		cout << 0 << ' ' << 0 << endl;
		cout << 0 << ' ' << m - 1 << endl;
		return 0;//test2
	}

	if(m == 1 and n == 1){
		cout << "1 1\n";
		cout << "0 0\n";
		cout << "1 0\n";
		cout << "0 1\n";
		return 0;
	}

	if(m >= n){
		cout << 0 << ' ' << 1 << endl;
		cout << n << ' ' << m << endl;
		cout << 0 << ' ' << 0 << endl;
		cout << n - 1 << ' ' << m << endl;
	}
	else{
		cout << 0 << ' ' << 1 << endl;
		cout << n << ' ' << m << endl;
		cout << 0 << ' ' << 0 << endl;
		cout << n << ' ' << m - 1 << endl;
	}
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main(){
	int n , m;
	cin >> n >> m;
	if(n == 0){
		cout << 0 << ' ' << 0 << endl;
		cout << 0 << ' ' << 1 << endl;
		cout << 0 << ' ' << 2 << endl;
		cout << 0 << ' ' << m << endl;
		return 0;//test2
	}
	cout << 0 << ' ' << 0 << endl;
	cout << 0 << ' ' << m << endl;
	cout << n << ' ' << m << endl;
	cout << m << ' ' << 0 << endl;
	//test1
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;

typedef pair < int , int > point;
typedef long double ld;
typedef long long int ll;

#define X first
#define Y second
#define pb push_back
#define mp make_pair

vector < point > p , helper;

int dx[4] = {0 , 0 , 1 , -1};
int dy[4] = {1 , -1 , 0 , 0};

vector <point>:: iterator itlow;

ld get_dis(point a , point b){
	ld ret = .0;
	ld cur1 = abs(a.X - b.X);
	ld cur2 = abs(a.Y - b.Y);

	ret = sqrt((cur1 * cur1) + (cur2 * cur2));
	return ret;
}

int main(){
	int n , m;
	cin >> n >> m;

	helper.push_back(mp(0 , 0));
	helper.push_back(mp(m , 0));
	helper.push_back(mp(0 , n));
	helper.push_back(mp(m , n));

	for(int i = 0 ; i < 4 ; i++){
		for(int j = 0 ; j < 4 ; j++){
			for(int k = 0 ; k < helper.size() ; k++){
				point now = helper[k];
				int x = now.X;
				int y = now.Y;

				x += dx[i];
				y += dy[i];

				if(x <= m and x >= 0 and y <= n and y >= 0){
					p.push_back(mp(x , y));
				}
			}
		}
	}
	p.push_back(mp(0 , 0));
	p.push_back(mp(m , 0));
	p.push_back(mp(0 , n));
	p.push_back(mp(m , n));

	sort(p.begin() , p.end());

    itlow = unique (p.begin(), p.end());

	p.resize(distance(p.begin(),itlow));

//	for(int i = 0 ; i < p.size() ; i++){
//		cout << p[i].X << ' ' << p[i].Y << endl;
//	}

	int ind[4];
	ind[0] = 0;
	ind[1] = 0;
	ind[2] = 0;
	ind[3] = 0;
	ld answer = .0;

	for(int i = 0 ; i < p.size() ; i++){
		for(int j = 0 ; j < p.size() ; j++){
			if(j == i)
				continue;
			for(int k = 0 ; k < p.size() ; k++){
				if(k == j or k == i)
					continue;
				for(int l = 0 ; l < p.size() ; l++){
					if(l == k or l == i or l == j)
						continue;
					ld cur = get_dis(p[i] , p[j]) + get_dis(p[j] , p[k]) + get_dis(p[k] , p[l]);
					if(cur > answer){
						answer = cur;
						ind[0] = i;
						ind[1] = j;
						ind[2] = k;
						ind[3] = l;
					}
				}
			}
		}
	}
	for(int i = 0 ; i < 4 ; i++){
		cout << p[ind[i]].X << ' ' << p[ind[i]].Y << endl;
	}
	cout.flush();
}


//When everything, everything, everything you touch turns to gold!

#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<utility>

using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 1e3 + 10;

int n, m;
vector<pair<int, int>>	ans, vec;
bool mark[MAXN][MAXN];
bool fl;

ld dis(ld a, ld b, ld c, ld d){
	ld ret = (a - c) * (a - c);
	ret += (b - d) * (b - d);
	return	sqrt(ret);
}

ld get(vector<pair<int, int>>	t){
	ld ret = 0;
	for (int i = 0; i < 3; i++)
		ret += dis(t[i].first, t[i].second, t[i + 1].first, t[i + 1].second);
	return	ret;
}

int main(){
	cin >> n >> m;
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= m; j++)
			if ((i < 2 && j < 2) || (n - i < 2 && m - j < 2))
				vec.push_back({i, j});

	sort(vec.begin(), vec.end());
	ld maxi = 0;
	do{
		vector<pair<int, int>>	sec;
		for (int i = 0; i < 4; i++)	sec.push_back(vec[i]);
		if (maxi < get(sec)){
			maxi = get(sec);
			ans.assign(sec.begin(), sec.end());
		}
	}while (next_permutation(vec.begin(), vec.end()));

	for (pair<int, int>	v:ans)
		cout << v.first << " " << v.second << "\n";
	return	0;
}


//When everything, everything, everything you touch turns to gold!

#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>

using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 1e3 + 10;

int n, m;
vector<pair<int, int>>	ans;
bool mark[MAXN][MAXN];
bool fl;

ld dis(ld a, ld b, ld c, ld d){
	ld ret = (a - c) * (a - c);
	ret += (b - d) * (b - d);
	return	ret;
}

int main(){
	cin >> n >> m;
	if (n > m){
		swap(n, m);
		fl = 1;
	}
	if (n == 0){
		ans.push_back({0, 1});
		ans.push_back({0, m});
		ans.push_back({0, 0});
		ans.push_back({0, m - 1});
	}
	else{
		ans.push_back({0, 1});
		ans.push_back({n, m});
		ans.push_back({0, 0});
		ans.push_back({n, m - 1});
	}

	for (pair<int, int>	v:ans)
		if (!fl)
			cout << v.first << " " << v.second << "\n";
		else
			cout << v.second << " " << v.first << "\n";
	return	0;
}


//When everything, everything, everything you touch turns to gold!

#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>

using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 1e3 + 10;

int n, m;
vector<pair<int, int>>	ans;
bool mark[MAXN][MAXN];

ld dis(ld a, ld b, ld c, ld d){
	ld ret = (a - c) * (a - c);
	ret += (b - d) * (b - d);
	return	ret;
}

int main(){
	cin >> n >> m;
	ans.push_back({0, 0});
	ans.push_back({n, m});
	mark[0][0] = mark[n][m] = 1;
	int x = n, y = m;
	for (int i = 0; i < 2; i++){
		ld maxi = 0;
		int a, b;
		for (int xx = 0; xx <= n; xx++)
			for (int yy = 0; yy <= m; yy++)
				if (!mark[xx][yy])
					if (dis(x, y, xx, yy) > maxi){
						maxi = dis(x, y, xx, yy);
						a = xx, b = yy;
					}
		ans.push_back({a, b});
		x = a, y = b;
	}

	for (pair<int, int>	v:ans)
		cout << v.first << " " << v.second << "\n";
	return	0;
}


//When everything, everything, everything you touch turns to gold!

#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<utility>

using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 1e3 + 10;

int n, m;
vector<pair<int, int>>	ans, vec, sec;
ld maxi = 0;
bool mark[MAXN][MAXN];

ld dis(ld a, ld b, ld c, ld d){
	ld ret = (a - c) * (a - c);
	ret += (b - d) * (b - d);
	return	ret;
}

ld get(vector<pair<int, int>>	t){
	ld ret = 0;
	for (int i = 0; i < 3; i++)
		ret += dis(t[i].first, t[i].second, t[i + 1].first, t[i + 1].second);
	return	ret;
}

void gen(int rem){
	if (rem == 0){
		if (maxi < get(sec)){
			maxi = get(sec);
			ans.assign(sec.begin(), sec.end());
		}
		return;
	}

	for (pair<int, int>	v:vec)
		if (!mark[v.first][v.second]){
			mark[v.first][v.second] = 1;
			sec.push_back(v);
			gen(rem - 1);
			sec.pop_back();
			mark[v.first][v.second] = 0;
		}
}

int main(){
	cin >> n >> m;
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= m; j++)
			if ((i < 3 && j < 3) || (n - i < 3 && m - j < 3))
				vec.push_back({i, j});

	sort(vec.begin(), vec.end());
	gen(4);

	for (pair<int, int>	v:ans)
		cout << v.first << " " << v.second << "\n";
	return	0;
}


//When everything, everything, everything you touch turns to gold!

#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<utility>

using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 1e3 + 10;

int n, m;
vector<pair<int, int>>	ans, vec, sec;
ld maxi = 0;
bool mark[MAXN][MAXN];

ld dis(ld a, ld b, ld c, ld d){
	ld ret = (a - c) * (a - c);
	ret += (b - d) * (b - d);
	return	ret;
}

ld get(vector<pair<int, int>>	t){
	ld ret = 0;
	for (int i = 0; i < 3; i++)
		ret += dis(t[i].first, t[i].second, t[i + 1].first, t[i + 1].second);
	return	ret;
}

void gen(int rem){
	if (rem == 0){
		if (maxi < get(sec)){
			maxi = get(sec);
			ans.assign(sec.begin(), sec.end());
		}
		return;
	}

	for (pair<int, int>	v:vec)
		if (!mark[v.first][v.second]){
			mark[v.first][v.second] = 1;
			sec.push_back(v);
			gen(rem - 1);
			sec.pop_back();
			mark[v.first][v.second] = 0;
		}
}

int main(){
	cin >> n >> m;
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= m; j++)
			if ((i < 4 && j < 4) || (n - i < 4 && m - j < 4))
				vec.push_back({i, j});
			else if ((n - i < 3 && j < 3) || (m - j < 3 && i < 3))
				vec.push_back({i, j});

	sort(vec.begin(), vec.end());
	gen(4);

	for (pair<int, int>	v:ans)
		cout << v.first << " " << v.second << "\n";
	return	0;
}


#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int xa, xb, xc, xd, ya, yb,yc,yd;
int n,m;
double dis1,dis2;
bool c;

double dis(int x1,int y1,int x2,int y2)
{
	return sqrt(pow(abs(x2-x1),2) + pow(abs(y2-y1),2));
}

int main()
{
	cin>>n>>m;
	if(m>n)
	{
		swap(n,m);
		c=true;
	}
	if(m==0)
	{
		xa=1;
		xb=n;
		xc=0;
		xd=n-1;
		ya=0;
		yb=0;
		yc=0;
		yd=0;
	}
	else
	{
		dis1=dis(0,0,n,m)*2+dis(0,0,n,0);
		dis2=dis(0,0,n,m)+dis(0,0,n,m-1)*2;
		if(dis1>dis2)
		{
			xa=0;
			xb=n;
			xc=0;
			xd=n;
			ya=0;
			yb=m;
			yc=m;
			yd=0;
		}
		else
		{
			xa=0;
			xb=n;
			xc=0;
			xd=n;
			ya=1;
			yb=m;
			yc=0;
			yd=m-1;
		}
	}
	if(c)
	{
		swap(xa,ya);
		swap(xb,yb);
		swap(xc,yc);
		swap(xd,yd);
	}
	cout<<xa<<" "<<ya<<endl<<xb<<" "<<yb<<endl<<xc<<" "<<yc<<endl<<xd<<" "<<yd<<endl;
	return 0;
}


#include<stdio.h>
#include<iostream>
using namespace std;

int Distance(int x1, int y1, int x2, int y2){
    return (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
}

int n, m;
int x1, x2, x3, x4, y1, y2, y3, y4;

int main()
{
    scanf("%d%d", &n, &m);
    bool change = false;
    if(m > n){
        swap(n, m);
        change = true;
    }
    if(m == 0){
        x1 = 1, x2 = n, x3 = 0, x4 = n-1;
        y1 = y2 = y3 = y4 = 0;
    }
    else{
        int dis1 = Distance(0, 0, n, m)*2+Distance(0, 0, n, 0);
        int dis2 = Distance(0, 0, n, m)+Distance(0, 0, n, m-1)*2;

        if(dis1 > dis2){
            x1 = 0, y1 = 0;
            x2 = n, y2 = m;
            x3 = 0, y3 = m;
            x4 = n, y4 = 0;
        }
        else{
            x1 = 0, y1 = 1;
            x2 = n, y2 = m;
            x3 = 0, y3 = 0;
            x4 = n, y4 = m-1;
        }
    }
    if(change){
        swap(x1, y1);
        swap(x2, y2);
        swap(x3, y3);
        swap(x4, y4);
    }
    printf("%d %d\n%d %d\n%d %d\n%d %d\n", x1, y1, x2, y2, x3, y3, x4, y4);

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
main()
{
    int n,m ; scanf("%d%d",&n,&m) ;
    if(n==0) printf("0 %d\n0 %d\n0 %d\n0 %d\n",0,m,1,m-1) ;
    else if(m==0) printf("%d 0\n%d 0\n%d 0\n%d 0\n",0,n,1,n-1) ;
    else printf("%d %d\n%d %d\n%d %d\n%d %d\n",
                0,0,n,m,1,0,n-1,m) ;
}


#include<bits/stdc++.h>
#define DB double
using namespace std;
main()
{
    int n,m ; scanf("%d%d",&n,&m) ;
    if(n==0) printf("0 %d\n0 %d\n0 %d\n0 %d\n",m-1,0,m,1) ;
    else if(m==0) printf("%d 0\n%d 0\n%d 0\n%d 0\n",n-1,0,n,1) ;
    else
    {
        DB d1=sqrt(n*n+m*m)+2*sqrt((n-1)*(n-1)+m*m) ;
        DB d2=sqrt(n*n+m*m)+2*sqrt((m-1)*(m-1)+n*n) ;
        DB d3=2*sqrt(n*n+m*m)+max(n,m) ;
        if(d3>=d1&&d3>=d2)
        {
            printf("0 0\n%d %d\n",n,m) ;
            if(n>=m) printf("0 %d\n%d 0\n",m,n) ;
            else printf("%d 0\n0 %d\n",n,m) ;
        }
        else if(n<=m) printf("%d %d\n0 0\n%d %d\n1 0\n",n-1,m,n,m) ;
        else printf("%d %d\n0 0\n%d %d\n0 1\n",n,m-1,n,m) ;
    }
}


#include<bits/stdc++.h>
using namespace std;
main()
{
    int n,m ; scanf("%d%d",&n,&m) ;
    if(n==0) printf("0 %d\n0 %d\n0 %d\n0 %d\n",m-1,0,m,1) ;
    else if(m==0) printf("%d 0\n%d 0\n%d 0\n%d 0\n",n-1,0,n,1) ;
    else if(n<=m) printf("%d %d\n%d %d\n%d %d\n%d %d\n",
                        0,0,n,m,n,0,0,m) ;
    else printf("%d %d\n%d %d\n%d %d\n%d %d\n",
                0,0,n,m,0,m,n,0) ;
}


#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <stdlib.h>
#include <sstream>
#include <assert.h>
#include <memory.h>
#include <complex>
#include <time.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define sz(x) (int)(x).size()

int main() {
    //freopen("cyclic.in","rt",stdin);
    //freopen("cyclic.out","wt",stdout);

	int n, m;
	scanf("%d %d", &n, &m);
	printf("%d %d\n", n - 1, m);
	printf("%d %d\n", 0, 0);
	printf("%d %d\n", n, m);
	printf("%d %d\n", 1, 0);

    return 0;
}


#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <stdlib.h>
#include <sstream>
#include <assert.h>
#include <memory.h>
#include <complex>
#include <time.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define sz(x) (int)(x).size()

int main() {
    //freopen("cyclic.in","rt",stdin);
    //freopen("cyclic.out","wt",stdout);

	int n, m;
	scanf("%d %d", &n, &m);
	if(n >= 2 && m >= 2 && !(n == 2 && m == 2) && !(n == 3 && m == 3)) {
		if(n < m) {
			printf("%d %d\n", n - 1, m);
			printf("%d %d\n", 0, 0);
			printf("%d %d\n", n, m);
			printf("%d %d\n", 1, 0);
		}
		else {
			printf("%d %d\n", n, m - 1);
			printf("%d %d\n", 0, 0);
			printf("%d %d\n", n, m);
			printf("%d %d\n", 0, 1);
		}
	}
	else if(n == 0) {
		printf("%d %d\n", 0, m-1);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", 0, m);
		printf("%d %d\n", 0, 1);
	}
	else if(m == 0) {
		printf("%d %d\n", n-1, 0);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", n, 0);
		printf("%d %d\n", 1, 0);
	}
	else if(n == 1) {
		printf("%d %d\n", n, m);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", n, 0);
		printf("%d %d\n", 0, m);
	}
	else if(m == 1) {
		printf("%d %d\n", n, m);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", 0, m);
		printf("%d %d\n", n, 0);
	}
	else if(n == 2 && m == 2) {
		printf("%d %d\n", n, m);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", n, 0);
		printf("%d %d\n", 0, m);
	}
	else if(n == 3 && m == 3) {
		printf("%d %d\n", n, m);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", n, 0);
		printf("%d %d\n", 0, m);
	}

    return 0;
}


#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <stdlib.h>
#include <sstream>
#include <assert.h>
#include <memory.h>
#include <complex>
#include <time.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define sz(x) (int)(x).size()

int n, m;

bool vis[1010][1010];

double bestans = 0;
vector<pair<int, int> > ans;
vector<pair<int, int> > cur;

void go(int cnt, int x, int y, double curlen) {
	if(cnt != 0) {
		if(vis[x][y]) return;
		vis[x][y] = true;
		cur.pb(mp(x, y));
	}
	if(cnt == 0) {
		for(int i = 0; i <= min(n, 4); i++) {
			go(1, i, 0, 0);
		}
		for(int i = 0; i <= min(m, 4); i++) {
			go(1, 0, i, 0);
		}
	}
	else if(cnt == 4) {
		if(bestans < curlen) bestans = curlen, ans = cur;
	}
	else {
		if(cnt & 1) {
			for(int i = n; i >= max(0, n-4); i--) {
				go(cnt+1, i, m, curlen + sqrt((double)(x-i)*(double)(x-i) + (double)(y-m) * (double)(y-m)));
			}
			for(int i = m; i >= max(0, m-4); i--) {
				go(cnt+1, n, i, curlen + sqrt((double)(x-n)*(double)(x-n) + (double)(y-i) * (double)(y-i)));
			}
		}
		else {
			for(int i = 0; i <= min(n, 4); i++) {
				go(cnt+1, i, 0, curlen + sqrt((double)(x-i)*(double)(x-i) + (double)y * (double)y));
			}
			for(int i = 0; i <= min(m, 4); i++) {
				go(cnt+1, 0, i, curlen + sqrt((double)x*(double)x + (double)(y-i) * (double)(y-i)));
			}
		}
	}
	if(cnt != 0)

		cur.pop_back(), vis[x][y] = false;
}

int main() {
    //freopen("cyclic.in","rt",stdin);
    //freopen("cyclic.out","wt",stdout);

	scanf("%d %d", &n, &m);

	go(0, 0, 0, 0);
	//printf("%.9lf\n", bestans);
	for(int i = 0; i < 4; i++) printf("%d %d\n", ans[i].first, ans[i].second);

    return 0;
}


#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <stdlib.h>
#include <sstream>
#include <assert.h>
#include <memory.h>
#include <complex>
#include <time.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define sz(x) (int)(x).size()

int main() {
    //freopen("cyclic.in","rt",stdin);
    //freopen("cyclic.out","wt",stdout);

	int n, m;
	scanf("%d %d", &n, &m);
	printf("%d %d\n", n, m - 1);
	printf("%d %d\n", 0, 0);
	printf("%d %d\n", n, m);
	printf("%d %d\n", 1, 0);

    return 0;
}


#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <stdlib.h>
#include <sstream>
#include <assert.h>
#include <memory.h>
#include <complex>
#include <time.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define sz(x) (int)(x).size()

int n, m;

bool vis[1010][1010];

double bestans = 0;
vector<pair<int, int> > ans;
vector<pair<int, int> > cur;

void go(int cnt, int x, int y, double curlen) {
	if(cnt != 0) {
		if(vis[x][y]) return;
		vis[x][y] = true;
		cur.pb(mp(x, y));
	}
	if(cnt == 0) {
		for(int i = 0; i <= min(n, 3); i++) {
			go(1, i, 0, 0);
		}
		for(int i = 0; i <= min(m, 3); i++) {
			go(1, 0, i, 0);
		}
	}
	else if(cnt == 4) {
		if(bestans < curlen) bestans = curlen, ans = cur;
	}
	else {
		if(cnt & 1) {
			for(int i = n; i >= max(0, n-3); i--) {
				go(cnt+1, i, m, curlen + sqrt((double)(x-i)*(double)(x-i) + (double)(y-m) * (double)(y-m)));
			}
			for(int i = m; i >= max(0, m-3); i--) {
				go(cnt+1, n, i, curlen + sqrt((double)(x-n)*(double)(x-n) + (double)(y-i) * (double)(y-i)));
			}
		}
		else {
			for(int i = 0; i <= min(n, 3); i++) {
				go(cnt+1, i, 0, curlen + sqrt((double)(x-i)*(double)(x-i) + (double)y * (double)y));
			}
			for(int i = 0; i <= min(m, 3); i++) {
				go(cnt+1, 0, i, curlen + sqrt((double)x*(double)x + (double)(y-i) * (double)(y-i)));
			}
		}
	}
	if(cnt != 0)

		cur.pop_back(), vis[x][y] = false;
}

int main() {
    //freopen("cyclic.in","rt",stdin);
    //freopen("cyclic.out","wt",stdout);

	scanf("%d %d", &n, &m);

	go(0, 0, 0, 0);
	//printf("%.9lf\n", bestans);
	for(int i = 0; i < 4; i++) printf("%d %d\n", ans[i].first, ans[i].second);

    return 0;
}


#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <stdlib.h>
#include <sstream>
#include <assert.h>
#include <memory.h>
#include <complex>
#include <time.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define sz(x) (int)(x).size()

int n, m;

bool vis[1010][1010];

double bestans = 0;
vector<pair<int, int> > ans;
vector<pair<int, int> > cur;

void go(int cnt, int x, int y, double curlen) {
	if(cnt != 0) {
		if(vis[x][y]) return;
		vis[x][y] = true;
		cur.pb(mp(x, y));
	}
	if(cnt == 0) {
		for(int i = 0; i <= min(n, 2); i++) {
			go(1, i, 0, 0);
		}
		for(int i = 0; i <= min(m, 2); i++) {
			go(1, 0, i, 0);
		}
	}
	else if(cnt == 4) {
		if(bestans < curlen) bestans = curlen, ans = cur;
	}
	else {
		if(cnt & 1) {
			for(int i = n; i >= max(0, n-2); i--) {
				go(cnt+1, i, m, curlen + sqrt((double)(x-i)*(double)(x-i) + (double)(y-m) * (double)(y-m)));
			}
			for(int i = m; i >= max(0, m-2); i--) {
				go(cnt+1, n, i, curlen + sqrt((double)(x-n)*(double)(x-n) + (double)(y-i) * (double)(y-i)));
			}
		}
		else {
			for(int i = 0; i <= min(n, 2); i++) {
				go(cnt+1, i, 0, curlen + sqrt((double)(x-i)*(double)(x-i) + (double)y * (double)y));
			}
			for(int i = 0; i <= min(m, 2); i++) {
				go(cnt+1, 0, i, curlen + sqrt((double)x*(double)x + (double)(y-i) * (double)(y-i)));
			}
		}
	}
	if(cnt != 0)

		cur.pop_back(), vis[x][y] = false;
}

int main() {
    //freopen("cyclic.in","rt",stdin);
    //freopen("cyclic.out","wt",stdout);

	scanf("%d %d", &n, &m);

	go(0, 0, 0, 0);
	//printf("%.9lf\n", bestans);
	for(int i = 0; i < 4; i++) printf("%d %d\n", ans[i].first, ans[i].second);

    return 0;
}


#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <stdlib.h>
#include <sstream>
#include <assert.h>
#include <memory.h>
#include <complex>
#include <time.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define sz(x) (int)(x).size()

int main() {
    //freopen("cyclic.in","rt",stdin);
    //freopen("cyclic.out","wt",stdout);

	int n, m;
	scanf("%d %d", &n, &m);
	if(n >= 2 && m >= 2 && !(n == 2 && m == 2)) {
		if(n < m) {
			printf("%d %d\n", n - 1, m);
			printf("%d %d\n", 0, 0);
			printf("%d %d\n", n, m);
			printf("%d %d\n", 1, 0);
		}
		else {
			printf("%d %d\n", n, m - 1);
			printf("%d %d\n", 0, 0);
			printf("%d %d\n", n, m);
			printf("%d %d\n", 0, 1);
		}
	}
	else if(n == 0) {
		printf("%d %d\n", 0, m-1);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", 0, m);
		printf("%d %d\n", 0, 1);
	}
	else if(m == 0) {
		printf("%d %d\n", n-1, 0);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", n, 0);
		printf("%d %d\n", 1, 0);
	}
	else if(n == 1) {
		printf("%d %d\n", n, m);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", n, 0);
		printf("%d %d\n", 0, m);
	}
	else if(m == 1) {
		printf("%d %d\n", n, m);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", 0, m);
		printf("%d %d\n", n, 0);
	}
	else if(n == 2 && m == 2) {
		printf("%d %d\n", n, m);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", n, 0);
		printf("%d %d\n", 0, m);
	}

    return 0;
}


#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <stdlib.h>
#include <sstream>
#include <assert.h>
#include <memory.h>
#include <complex>
#include <time.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define sz(x) (int)(x).size()

int main() {
    //freopen("cyclic.in","rt",stdin);
    //freopen("cyclic.out","wt",stdout);

	int n, m;
	scanf("%d %d", &n, &m);
	if(n >= 2 && m >= 2) {
		if(n < m) {
			printf("%d %d\n", n - 1, m);
			printf("%d %d\n", 0, 0);
			printf("%d %d\n", n, m);
			printf("%d %d\n", 1, 0);
		}
		else {
			printf("%d %d\n", n, m - 1);
			printf("%d %d\n", 0, 0);
			printf("%d %d\n", n, m);
			printf("%d %d\n", 0, 1);
		}
	}
	else if(n == 0) {
		printf("%d %d\n", 0, m-1);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", 0, m);
		printf("%d %d\n", 0, 1);
	}
	else if(m == 0) {
		printf("%d %d\n", n-1, 0);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", n, 0);
		printf("%d %d\n", 1, 0);
	}
	else if(n == 1) {
		printf("%d %d\n", n, m);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", n, 0);
		printf("%d %d\n", 0, m);
	}
	else if(m == 1) {
		printf("%d %d\n", n, m);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", 0, m);
		printf("%d %d\n", n, 0);
	}

    return 0;
}


#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <stdlib.h>
#include <sstream>
#include <assert.h>
#include <memory.h>
#include <complex>
#include <time.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define sz(x) (int)(x).size()

int n, m;

bool vis[1010][1010];

double bestans = 0;
vector<pair<int, int> > ans;
vector<pair<int, int> > cur;

void go(int cnt, int x, int y, double curlen) {
	if(cnt != 0) {
		if(vis[x][y]) return;
		vis[x][y] = true;
		cur.pb(mp(x, y));
	}
	if(cnt == 0) {
		for(int i = 0; i <= min(n, 4); i++) {
			go(1, i, 0, 0);
		}
		for(int i = 0; i <= min(m, 4); i++) {
			go(1, 0, i, 0);
		}
	}
	else if(cnt == 4) {
		if(bestans < curlen) bestans = curlen, ans = cur;
	}
	else {
		if(cnt & 1) {
			for(int i = n; i >= max(0, n-4); i--) {
				go(cnt+1, i, 0, curlen + sqrt((double)(x-i)*(double)(x-i) + (double)y * (double)y));
			}
			for(int i = m; i >= max(0, m-4); i--) {
				go(cnt+1, 0, i, curlen + sqrt((double)x*(double)x + (double)(y-i) * (double)(y-i)));
			}
		}
		else {
			for(int i = 0; i <= min(n, 4); i++) {
				go(cnt+1, i, m, curlen + sqrt((double)(x-i)*(double)(x-i) + (double)y * (double)y));
			}
			for(int i = 0; i <= min(m, 4); i++) {
				go(cnt+1, n, i, curlen + sqrt((double)x*(double)x + (double)(y-i) * (double)(y-i)));
			}
		}
	}
	if(cnt != 0)

		cur.pop_back(), vis[x][y] = false;
}

int main() {
    //freopen("cyclic.in","rt",stdin);
    //freopen("cyclic.out","wt",stdout);

	scanf("%d %d", &n, &m);

	go(0, 0, 0, 0);
	for(int i = 0; i < 4; i++) printf("%d %d\n", ans[i].first, ans[i].second);

    return 0;
}


#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <stdlib.h>
#include <sstream>
#include <assert.h>
#include <memory.h>
#include <complex>
#include <time.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define sz(x) (int)(x).size()

int main() {
    //freopen("cyclic.in","rt",stdin);
    //freopen("cyclic.out","wt",stdout);

	int n, m;
	scanf("%d %d", &n, &m);
	if(n >= 2 && m >= 2) {
		printf("%d %d\n", n - 1, m);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", n, m);
		printf("%d %d\n", 1, 0);
	}
	else if(n == 0) {
		printf("%d %d\n", 0, m);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", 0, m-1);
		printf("%d %d\n", 0, 1);
	}
	else if(m == 0) {
		printf("%d %d\n", n, 0);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", n-1, 0);
		printf("%d %d\n", 1, 0);
	}
	else if(n == 1) {
		printf("%d %d\n", n, m);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", n, 0);
		printf("%d %d\n", 0, m);
	}
	else if(m == 1) {
		printf("%d %d\n", n, m);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", 0, m);
		printf("%d %d\n", n, 0);
	}

    return 0;
}


#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <stdlib.h>
#include <sstream>
#include <assert.h>
#include <memory.h>
#include <complex>
#include <time.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define sz(x) (int)(x).size()

int main() {
    //freopen("cyclic.in","rt",stdin);
    //freopen("cyclic.out","wt",stdout);

	int n, m;
	scanf("%d %d", &n, &m);
	if(n >= 2 && m >= 2) {
		if(n > m) {
			printf("%d %d\n", n - 1, m);
			printf("%d %d\n", 0, 0);
			printf("%d %d\n", n, m);
			printf("%d %d\n", 1, 0);
		}
		else {
			printf("%d %d\n", n, m - 1);
			printf("%d %d\n", 0, 0);
			printf("%d %d\n", n, m);
			printf("%d %d\n", 0, 1);
		}
	}
	else if(n == 0) {
		printf("%d %d\n", 0, m-1);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", 0, m);
		printf("%d %d\n", 0, 1);
	}
	else if(m == 0) {
		printf("%d %d\n", n-1, 0);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", n, 0);
		printf("%d %d\n", 1, 0);
	}
	else if(n == 1) {
		printf("%d %d\n", n, m);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", n, 0);
		printf("%d %d\n", 0, m);
	}
	else if(m == 1) {
		printf("%d %d\n", n, m);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", 0, m);
		printf("%d %d\n", n, 0);
	}

    return 0;
}


#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <stdlib.h>
#include <sstream>
#include <assert.h>
#include <memory.h>
#include <complex>
#include <time.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long
#define sz(x) (int)(x).size()

int main() {
    //freopen("cyclic.in","rt",stdin);
    //freopen("cyclic.out","wt",stdout);

	int n, m;
	scanf("%d %d", &n, &m);
	if(n >= 2 && m >= 2) {
		printf("%d %d\n", n - 1, m);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", n, m);
		printf("%d %d\n", 1, 0);
	}
	else if(n == 0) {
		printf("%d %d\n", 0, m-1);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", 0, m);
		printf("%d %d\n", 0, 1);
	}
	else if(m == 0) {
		printf("%d %d\n", n-1, 0);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", n, 0);
		printf("%d %d\n", 1, 0);
	}
	else if(n == 1) {
		printf("%d %d\n", n, m);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", n, 0);
		printf("%d %d\n", 0, m);
	}
	else if(m == 1) {
		printf("%d %d\n", n, m);
		printf("%d %d\n", 0, 0);
		printf("%d %d\n", 0, m);
		printf("%d %d\n", n, 0);
	}

    return 0;
}


#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
int n,m;bool f[20];
pair<int,int> ans[5],tt[5];
vector<pair<int,int> > a;
double maxi;
void dfs(int p){
	if(p==4){
		double t=0;
		for(int i=1;i<4;i++){
			double t1=(double)(abs(tt[i].first-tt[i-1].first));
			double t2=(double)(abs(tt[i].second-tt[i-1].second));
			t1=t1*t1;
			t2=t2*t2;
			t=t+sqrt(t1+t2);
		}
		if(t>maxi){
			maxi=t;
			for(int i=0;i<4;i++)ans[i]=tt[i];
		}
		return;
	}
	for(int i=0;i<a.size();i++)if(f[i]==0){f[i]=1;tt[p]=a[i];dfs(p+1);f[i]=0;}
}
int main(){
	scanf("%d%d",&n,&m);
	int x,y;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if((i<2||n-i<2)&&(j<2||m-j<2))a.push_back(make_pair(i,j));
		}
	}
	dfs(0);
	for(int i=0;i<4;i++){
		printf("%d %d\n",ans[i].first,ans[i].second);
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <string>
#include <memory.h>

#define sci(a) scanf("%d", &a)
#define scii(a, b) scanf("%d%d", &a, &b)
#define sciii(a, b, c) scanf("%d%d%d", &a, &b, &c)

#define scid(a) int a; sci(a)
#define sciid(a, b) int a, b; scii(a, b)
#define sciiid(a, b, c) int a, b, c; sciii(a, b, c)

#define rea(a, n) for (int i = 0; i < n; i++) sci(a[i])

#define init_cin ios_base::sync_with_stdio(false); cin.tie(0);

typedef long long lint;

using namespace std;

int main() {
    sciid(n, m);
    if (n == 0) {
        cout << 0 << " " << 1 << "\n";
        cout << 0 << " " << m << "\n";
        cout << 0 << " " << 0 << "\n";
        cout << 0 << " " << m - 1 << "\n";
        return 0;
    }
    if (m == 0) {
        cout << 1 << " " << 0 << "\n";
        cout << n << " " << 0 << "\n";
        cout << 0 << " " << 0 << "\n";
        cout << n - 1 << " " << 0 << "\n";
        return 0;
    }
    double l1 = 2 * sqrt(n * n + m * m) + max(n, m);
    double l2 = sqrt(n * n + m * m) + 2 * sqrt(max(n, m) * max(n, m) + (min(n, m) - 1) * (min(n, m) - 1));
    if (l1 > l2) {
        cout << 0 << " " << 0 << "\n";
        cout << n << " " << m << "\n";
        if (n > m) {
            cout << 0 << " " << m << "\n";
            cout << n << " " << 0 << "\n";
        } else {
            cout << n << " " << 0 << "\n";
            cout << 0 << " " << m << "\n";
        }
        return 0;
    }
    if (n > m) {
        cout << 0 << " " << 1 << "\n";
        cout << n << " " << m << "\n";
        cout << 0 << " " << 0 << "\n";
        cout << n << " " << m - 1 << "\n";
    } else {
        cout << n - 1 << " " << m << "\n";
        cout << 0 << " " << 0 << "\n";
        cout << n << " " << m << "\n";
        cout << 1 << " " << 0 << "\n";
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <string>
#include <memory.h>

#define sci(a) scanf("%d", &a)
#define scii(a, b) scanf("%d%d", &a, &b)
#define sciii(a, b, c) scanf("%d%d%d", &a, &b, &c)

#define scid(a) int a; sci(a)
#define sciid(a, b) int a, b; scii(a, b)
#define sciiid(a, b, c) int a, b, c; sciii(a, b, c)

#define rea(a, n) for (int i = 0; i < n; i++) sci(a[i])

#define init_cin ios_base::sync_with_stdio(false); cin.tie(0);

typedef long long lint;

using namespace std;

int main() {
    sciid(n, m);
    if (n == 1 && m == 1) {
        cout << "0 0\n1 1\n1 0\n0 1";
        return 0;
    }
    if (n == 0) {
        cout << 0 << " " << 1 << "\n";
        cout << 0 << " " << m << "\n";
        cout << 0 << " " << 0 << "\n";
        cout << 0 << " " << m - 1 << "\n";
    } else if (m == 0) {
        cout << 1 << " " << 0 << "\n";
        cout << n << " " << 0 << "\n";
        cout << 0 << " " << 0 << "\n";
        cout << n - 1 << " " << 0 << "\n";
    } else if (n > m) {
        cout << 1 << " " << 0 << "\n";
        cout << n << " " << m << "\n";
        cout << 0 << " " << 0 << "\n";
        cout << n - 1 << " " << m << "\n";
    } else {
        cout << 0 << " " << 1 << "\n";
        cout << n << " " << m << "\n";
        cout << 0 << " " << 0 << "\n";
        cout << n << " " << m - 1 << "\n";
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <string>
#include <memory.h>

#define sci(a) scanf("%d", &a)
#define scii(a, b) scanf("%d%d", &a, &b)
#define sciii(a, b, c) scanf("%d%d%d", &a, &b, &c)

#define scid(a) int a; sci(a)
#define sciid(a, b) int a, b; scii(a, b)
#define sciiid(a, b, c) int a, b, c; sciii(a, b, c)

#define rea(a, n) for (int i = 0; i < n; i++) sci(a[i])

#define init_cin ios_base::sync_with_stdio(false); cin.tie(0);

typedef long long lint;

using namespace std;

int main() {
    sciid(n, m);
    if (n == 0) {
        cout << 0 << " " << 1 << "\n";
        cout << 0 << " " << m << "\n";
        cout << 0 << " " << 0 << "\n";
        cout << 0 << " " << m - 1 << "\n";
    } else if (m == 0) {
        cout << 1 << " " << 0 << "\n";
        cout << n << " " << 0 << "\n";
        cout << 0 << " " << 0 << "\n";
        cout << n - 1 << " " << 0 << "\n";
    } else if (n > m) {
        cout << 0 << " " << 0 << "\n";
        cout << n << " " << m << "\n";
        cout << 0 << " " << 1 << "\n";
        cout << n << " " << m - 1 << "\n";
    } else {
        cout << 0 << " " << 0 << "\n";
        cout << n << " " << m << "\n";
        cout << 1 << " " << 0 << "\n";
        cout << n - 1 << " " << m << "\n";
    }

    return 0;
}