#pragma GCC optimize(2)
#pragma GCC optimize(3)
 #include<bits/stdc++.h>
 #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
  using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define fort while(t--)
#define ld long double
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define vd vector<double>
#define vi vector<int>
#define pd pair<double,double>
#define vc vector<char>
#define vs vector<string>
#define pi pair<int,int>
#define pl pair<ll,ll>
#define ull unsigned long long int
const ll mod= 1e9+7;

template <class nmsl> inline void read(nmsl &x)
{
	x=0;
	char ch=getchar(), w=0;
	while(!isdigit(ch))w=(ch=='-'), ch=getchar();
	while(isdigit(ch))x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
	x=w?-x:x;
}

ll power(ll x,ll y,ll z){
	x=(x%z);
	ll res=1LL;
	while(y>0){
		if(y&1){
			res=(res*x)%z;
		}
		x=(x*x)%z;
		y=y>>1;
	}
	return res;
}

ll modInv(ll n, ll mod)
{
    return power(n, mod-2, mod);
}
ll nCrModP(ll n, ll r, ll mod)
{
   if (r==0)
      return 1;
    ll fac[n+1];
    fac[0] = 1;
    for (ll i=1 ; i<=n; i++)
        fac[i] = fac[i-1]*i%mod;

    return (fac[n]* modInv(fac[r], mod) % mod *modInv(fac[n-r], mod) % mod) % mod;
}

ll countSetBits(ll n)
{
    ll count = 0;
    while (n)
    {
    n &= (n-1) ;
    count++;
    }
    return count;
}

int main() {
	#ifndef ONLINE_JUDGE
	//for getting input from input.txt
	freopen("input2.txt","r",stdin);
	//for writing output to output.txt
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,k;
	cin>>n>>k;
	if(n==1)
	{
		cout<<k<<endl;
		return 0;
	}
	if(n>k)
	{
		vector<int> vt{k};
		for(int i=0;i<n-1;i++)
			vt.pb(0);
		int kd=-1;
		for(int i=0;i<n;i++)
		{
			kd++;
			for(int j=0;j<n;j++)
			{
				cout<<vt[(kd+j)%n]<<" ";
			}
			cout<<endl;
		}
		return 0;
	}
	int s=((n-1)*n)/2;
	vector<int> v;
	for(int i=1;i<n;i++)
		v.pb(i);
	int factor=k/s;
		for(int j=0;j<n;j++)
		{
			v[j]*=factor;
		}

	int rem=k;
	if(factor*s>0)
		rem=k%(factor*s);
	v.pb(rem);
	sort(v.begin(),v.end());
	int kd=-1;
	for(int i=0;i<n;i++)
	{
		kd++;
		for(int j=0;j<n;j++)
		{
			cout<<v[(kd+j)%n]<<" ";
		}
		cout<<endl;
	}
	return 0;
}


#include <iostream>

using namespace std;

int main(){
	int n , k;
	cin >> n >> k;
	int x = 0;
	int y = n - 1;
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < n ; j++){
			if(i == x && j == y){
				x += 1;
				y -= 1;
				cout << k << " ";
			}else cout << "0" << " ";
		}
		cout << endl;
	}
}


#include<iostream>
using namespace std;
int main()
{
    int n,k,i,j;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if(i==j)
                cout<<k<<" ";
            else
                cout<<0;
        }
        cout<<"\n";
    }
    return 0;
}


#include<iostream>
using namespace std;
int main()
{
    int n,k,i,j;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if(i==j)
                cout<<k;
            else
                cout<<0;
        }
        cout<<"\n";
    }
    return 0;
}


/*  Author: cf:Tarun_19/cc:tarun_19_
    E-mail: tarunkumar281200@gmail.com
=========="Impossible only means that you haven't found the solution yet"=======
*/#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vpll vector<pair<ll,ll>>
#define prqueue priority_queue<ll,vector<ll>,greater<ll>>
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ff first
#define ss second
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(), v.end()
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<=n;i++)
#define fab(i,a,b) for(i=a;i<=b;i++)
#define f0r(i,n) for(i=n-1;i>=0;i--)
#define f1r(i,n) for(i=n;i>=1;i--)
#define fabr(i,a,b) for(i=b;i>=a;i--)
#define memo(a,b) memset(a,b,sizeof(a))
#define display(x) for(auto dsp:x)cout<<dsp<<" ";cout<<"\n";
#define hi cout<<"hi\n"
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ln "\n"
using namespace std;
const ld pi=acos(-1);const ll mod=1e9+7;
const ll MAX=INT_MAX;const ll MIN=INT_MIN;
ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
bool sortbysec(pair<ll,ll> a,pair<ll,ll> b)//(i+1,i)
{return (a.second<b.second);}
ll lcm(ll x,ll y){return (x*y)/__gcd(x,y);}
ll power(ll x,ll y)//0^0=1
{ll res=1;x=x%mod;if(x==0)return 0;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
ll inverse(ll n)
{return power(n,mod-2);}
ll nCkmod(ll n,ll k)
{ll i,r=1;if(n<k)return 0;for(i=n;i>n-k;i--)r=(r*i)%mod;for(i=1;i<=k;i++)r=(r*inverse(i))%mod;return r;}
ll nCk(ll n,ll k)//TLE
{ll C[k+1]={0};C[0]=1;for(ll i=1;i<=n;i++)for(ll j=min(i,k);j>0;j--)C[j]=C[j]+C[j-1];return C[k];}
bool isPrime(ll n)
{if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(int i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}

int main()
{
    FAST;
    ll t,n,i,j,k,len,x,y,z,c,f,flag,p,q,mx,mn,l,r,sum,ans,tmp,it,pos,avg,m,cnt;
    string s;
    char ch;
    vll v;
    vpll vec;
    unordered_map<ll,ll> mappu;
    pair<ll,ll> pr;
    t=1;
    while(t--)
    {
        f=0;sum=0;flag=0;ans=0;cnt=0;v.clear();mappu.clear();vec.clear();
        cin>>n>>k;
        f0(i,n){
        f0(j,n)
        {
            tmp=0;
            if(i==j) tmp=k;
            cout<<tmp;
        }cout<<ln;}

    }
	return 0;
}


/*  Author: cf:Tarun_19/cc:tarun_19_
    E-mail: tarunkumar281200@gmail.com
=========="Impossible only means that you haven't found the solution yet"=======
*/#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vpll vector<pair<ll,ll>>
#define prqueue priority_queue<ll,vector<ll>,greater<ll>>
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ff first
#define ss second
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(), v.end()
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<=n;i++)
#define fab(i,a,b) for(i=a;i<=b;i++)
#define f0r(i,n) for(i=n-1;i>=0;i--)
#define f1r(i,n) for(i=n;i>=1;i--)
#define fabr(i,a,b) for(i=b;i>=a;i--)
#define memo(a,b) memset(a,b,sizeof(a))
#define display(x) for(auto dsp:x)cout<<dsp<<" ";cout<<"\n";
#define hi cout<<"hi\n"
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ln "\n"
using namespace std;
const ld pi=acos(-1);const ll mod=1e9+7;
const ll MAX=INT_MAX;const ll MIN=INT_MIN;
ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
bool sortbysec(pair<ll,ll> a,pair<ll,ll> b)//(i+1,i)
{return (a.second<b.second);}
ll lcm(ll x,ll y){return (x*y)/__gcd(x,y);}
ll power(ll x,ll y)//0^0=1
{ll res=1;x=x%mod;if(x==0)return 0;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
ll inverse(ll n)
{return power(n,mod-2);}
ll nCkmod(ll n,ll k)
{ll i,r=1;if(n<k)return 0;for(i=n;i>n-k;i--)r=(r*i)%mod;for(i=1;i<=k;i++)r=(r*inverse(i))%mod;return r;}
ll nCk(ll n,ll k)//TLE
{ll C[k+1]={0};C[0]=1;for(ll i=1;i<=n;i++)for(ll j=min(i,k);j>0;j--)C[j]=C[j]+C[j-1];return C[k];}
bool isPrime(ll n)
{if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(int i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}

int main()
{
    FAST;
    ll t,n,i,j,k,len,x,y,z,c,f,flag,p,q,mx,mn,l,r,sum,ans,tmp,it,pos,avg,m,cnt;
    string s;
    char ch;
    vll v;
    vpll vec;
    unordered_map<ll,ll> mappu;
    pair<ll,ll> pr;
    t=1;
    while(t--)
    {
        f=0;sum=0;flag=0;ans=0;cnt=0;v.clear();mappu.clear();vec.clear();
        cin>>n>>k;
        f0(i,n){
        f0(j,n)
        {
            tmp=0;
            if(i==j) tmp=k;
            cout<<tmp<<" ";
        }cout<<ln;}

    }
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
    int n,m,k,i,j;
    cin>>n>>k;
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
        {
            if(i==j)
                cout<<k;
            if(j>1)
                cout<<' ';

            else
                cout<<0;

        }
        cout<<endl;
    }
    return 0;

}


#include<iostream>
using namespace std;
int main()
{
    int n,m,k,i,j;
    cin>>n>>k;
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
        {
            if(i==j && i==n)
                cout<<k;
            else
                cout<<0;
            cout<<' ';

        }
        cout<<endl;
    }
    return 0;

}


#include<iostream>
using namespace std;
int main()
{
    int n,m,k,i,j;
    cin>>n>>k;
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
        {
            if(i==j)
                cout<<k;
            else
                cout<<0;
            cout<<' ';

        }
        cout<<endl;
    }
    return 0;

}


#include<iostream>
using namespace std;
int main()
{
    int n,m,k,i,j;
    cin>>n>>k;
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
        {
            if(j>1)
                cout<<' ';
            if(i==j)
                cout<<k;
            else
                cout<<0;

        }
        cout<<endl;
    }
    return 0;

}


#include <cstdio>

int n, k;

int main()
{
    scanf("%d %d", &n, &k);
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
            if(i==j) printf("%d", k);
            else     printf("0");
        printf("\n");
    }

    return 0;
}


#include <cstdio>

int n, k;

int main()
{
    scanf("%d %d", &n, &k);
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
            if(i==j) printf("%d ", k);
            else     printf("0 ");
        printf("\n");
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int md[1001][1001];

int main(){

	int x,y;
	cin >> x >> y;
	for(int i = 0; i < x; ++i){
		for(int j = 0; j < x; ++j){
			if(i == j) md[i][j]==y;
		}
	}

	for(int i = 0; i < x; ++i){
		for(int j = 0; j < x; ++j){
			cout << md[i][j] << " ";
		}cout << "\n";
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int md[1001][1001];

int main(){

	int x,y;
	cin >> x >> y;
	x = 2, y = 4;
	for(int i = 0; i < x; ++i){
		for(int j = 0; j < x; ++j){
			if(i == j) {
				md[i][j]=y;
			}
		}
	}

	for(int i = 0; i < x; ++i){
		for(int j = 0; j < x; ++j){
			cout << md[i][j] << " ";
		}cout << "\n";
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int md[1001][1001];

int main(){

	int x,y;
	cin >> x >> y;
// 	x = 2, y = 4;
	for(int i = 0; i < x; ++i){
		for(int j = 0; j < x; ++j){
			if(i == j) {
				md[i][j]=y;
			}
		}
	}

	for(int i = 0; i < x; ++i){
		for(int j = 0; j < x; ++j){
			cout << md[i][j] << " ";
		}cout << "\n";
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define loop() while(t--)
#define pb push_back

void solve(){
int n,k;
cin>>n>>k;
int arr[n],sum=0;
rep(i,n){
    if(i!=n-1 && (sum+i)<k)
    {
        arr[i]=i;sum+=i;
    }
    else if(i==n-1 && sum<k) arr[i]=k-sum;
    else arr[i]=0;
}
rep(i,n){ rep(j,n) cout<<arr[(j+i)%n]<<" "; cout<<"\n";}

}

int main(){
int t=1;
// cin>>t;

loop(){
solve();

}

return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define loop() while(t--)
#define pb push_back

void solve(){
int n,k;
cin>>n>>k;
int arr[n],sum=0;
rep(i,n){
    if(i!=n-1 && sum<k)
    {
        arr[i]=i;sum+=i;
    }
    else if(i==n-1 && sum<k) arr[i]=k-sum;
    else arr[i]=0;
}
rep(i,n){ rep(j,n) cout<<arr[(j+i)%n]<<" "; cout<<"\n";}
}

int main(){
int t=1;
// cin>>t;

loop(){
solve();

}

return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define loop() while(t--)
#define pb push_back

void solve(){
int n,k;
cin>>n>>k;
int arr[n],sum=0;
rep(i,n){
    if(i!=n-1 && sum<k)
    {
        arr[i]=i;sum+=i;
    }
    else arr[i]=k-sum;
}
rep(i,n){ rep(j,n) cout<<arr[(j+i)%n]<<" "; cout<<"\n";}
}

int main(){
int t=1;
// cin>>t;

loop(){
solve();

}

return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define loop() while(t--)
#define pb push_back

void solve(){
int n,k;
cin>>n>>k;
int arr[n],sum=0;
rep(i,n){
    if(i!=n-1 && sum<k)
    {
        arr[i]=i;sum+=i;
    }
    else arr[i]=0;
}
rep(i,n){ rep(j,n) cout<<arr[(j+i)%n]<<" "; cout<<"\n";}
}

int main(){
int t=1;
// cin>>t;

loop(){
solve();

}

return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,i,j;
	cin>>a>>b;
	for(i=1; i<=a; i++){
		for(j=1; j<=a; j++){
			if(j==i)cout<<b" ";
			else cout<<0" ";
		}
		cout<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,i,j;
	cin>>a>>b;
	for(i=1; i<=a; i++){
		for(j=1; j<=a; j++){
			if(j==i)cout<<b;
			else cout<<0;
		}
		cout<<endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,i,j;
	cin>>a>>b;
	for(i=1; i<=a; i++){
		for(j=1; j<=a; j++){
		        if(j==i){
				cout<<b;
			}
			else {
				cout<<0;
			}
			cout<<" ";
		}
		cout<<endl;
	}
}


 #include <bits/stdc++.h>
using namespace std;
int get_pgcd(int a, int b)
{
    int pgcd = 0;

    while(1)
    {
        pgcd = a % b;
        if(pgcd == 0)
        {
            pgcd = b;
            break;
        }
        a = b;
        b = pgcd;
    }

    return pgcd;
}
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef vector<pii> vpii;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpr(i,n) for(int i=n-1;i>=0;i--)
int main ()
{int n,k;
cin>>n>>k;
lp(i,n)
{
lp(j,n)
{if (i==j) cout<<k ;else
cout<<0;}
cout<<endl;
}}


 #include <bits/stdc++.h>
using namespace std;
int get_pgcd(int a, int b)
{
    int pgcd = 0;

    while(1)
    {
        pgcd = a % b;
        if(pgcd == 0)
        {
            pgcd = b;
            break;
        }
        a = b;
        b = pgcd;
    }

    return pgcd;
}
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef vector<pii> vpii;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpr(i,n) for(int i=n-1;i>=0;i--)
int main ()
{int n,k;
cin>>n>>k;
lp(i,n)
{
lp(j,n)
{if (i==j) cout<<k<<" ";else
cout<<0<<" ";}
cout<<endl;
}}


 #include <bits/stdc++.h>
using namespace std;
int get_pgcd(int a, int b)
{
    int pgcd = 0;

    while(1)
    {
        pgcd = a % b;
        if(pgcd == 0)
        {
            pgcd = b;
            break;
        }
        a = b;
        b = pgcd;
    }

    return pgcd;
}
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef vector<pii> vpii;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpr(i,n) for(int i=n-1;i>=0;i--)
int main ()
{int n,k;
cin>>n>>k;
lp(i,n)
{
lp(j,n)
{
cout<<0;}
cout<<endl;
}}


#include<bits/stdc++.h>
using namespace std;
int main(){
      int n,k; cin>>n>>k;
      for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                  if(i==j) cout<<k<<' ';
                  else cout<<0<<' ';
            }cout<<endl;
      }

      return 0;

}


#include<iostream>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
           if(j==i) cout<<"k ";
           else cout<<"0 ";
        }
    }
    return 0;
}


#include<iostream>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    string s=k;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
           if(j==i) cout<<"s ";
           else cout<<"0 ";
        }
    }
    return 0;
}


#include <iostream>
using namespace std;

int main() {
	int n,k; cin>>n>>k;
	int p=-1;//cout<<n<<k;
	for(int i=0;i<n;++i){
	++p;cout<<endl;
			for(int ii=0;ii<n-1;++ii){
			if(p==ii)
			cout<<k+1-(n)<<" ";
			cout<<1<<" ";
			}
}cout<<	k+1-(n);
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int n,k; cin>>n>>k;
	int p=-1;//cout<<n<<k;
	for(int i=0;i<n;++i){
	++p;cout<<endl;
			for(int ii=0;ii<n-1;++ii){
			if(p==ii)
			cout<<k+1-(n);
			cout<<1;
			}
}cout<<	k+1-(n);
	return 0;
}


#include <bits/stdc++.h>
#include<vector>
#include<string>
#include<iostream>
#include<stack>
#include <cmath>
using namespace std;

int main(){
int n,k;
cin>>n>>k;
int m=n;
int x[n][m];
for(int i=0;i<n;i++){
	for(int j=0;j<m;j++){
		x[i][j]=0;
	}
}

for(int i=0;i<n;i++){
	for(int j=0;j<m;j++){
		if(i==j){
			x[i][j]=k;
		}

	}
}
for(int i=0;i<n;i++){
	for(int j=0;j<m;j++){
		cout<<x[i][j];
	}
	cout<<'\n';
}

return 0;
}


#include <bits/stdc++.h>
#include<vector>
#include<string>
#include<iostream>
#include<stack>
#include <cmath>
using namespace std;

int main(){
int n,k;
cin>>n>>k;
int m=n;
int x[n][m];
for(int i=0;i<n;i++){
	for(int j=0;j<m;j++){
		x[i][j]=0;
	}
}

for(int i=0;i<n;i++){
	for(int j=0;j<m;j++){
		if(i==j){
			x[i][j]=k;
		}

	}
}
for(int i=0;i<n;i++){
	for(int j=0;j<m;j++){
		cout<<x[i][j]<<" ";
	}
	cout<<'\n';
}

return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n , k;
    cin >> n >> k;
    int a[n][n];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i==j)
                a[i][j] = k;
            else
                a[i][j] = 0;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    int a[n][n];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i==j)
                a[i][j] = k;
            else
                a[i][j] = 0;
        }
    }
   for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n , k;
    cin >> n >> k;
    int a[n][n];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i==j)
                a[i][j] = k;
            else
                a[i][j] = 0;
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;i<n;j++)
        {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    for (ll i=0; i<n; i++)
    {
        for (ll j=0; j<n; j++)
        {
            if (i==j)
            {
                cout<<k<<" ";
            }
            else
            {
                cout<<0<<" ";
            }
        }
        cout<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<n; j++)
        {
            if (i==j)
            {
                cout<<k<<" ";
            }
            else
            {
                cout<<0<<" ";
            }
        }
        cout<<endl;
    }

    return 0;
}


import java.util.*;
import static java.lang.System.out;

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
	static final long mod = (int)1e9+7;
	static final long M = (int)1e9+7;

	static class Reader
	{
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader()
		{
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException
		{
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String next() throws IOException
		{
			byte[] buf = new byte[64]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1)
			{
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException
		{
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do
			{
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}
		int[] readArray(int n) throws IOException {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}

		public long nextLong() throws IOException
		{
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			}
			while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException
		{
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			}
			while ((c = read()) >= '0' && c <= '9');

			if (c == '.')
			{
				while ((c = read()) >= '0' && c <= '9')
				{
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException
		{
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException
		{
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException
		{
			if (din == null)
				return;
			din.close();
		}

	}

	public static int digitSum(int n)
	{
		int sum =0;
		while(n > 0)
		{
			int last = n%10;
			sum+=last;
			n/=10;
		}
		return sum;
	}

	public static boolean isPrime(int n) {
		for(int i = 2;i*i<=n;i++)
		{
			if(n%i == 0)
			{
				return false;
			}
		}
		return true;
	}

	public static int gcd(int a, int b)
	{
		if(b == 0)
		 return a;

		else
		return gcd(b,a%b);
	}

	public static int traverser(int nums[], int n, int k)
    {
        int product = 1;

        if (nums[n - 1] == 0 && k % 2 != 0)
            return 0;

        if (nums[n - 1] <= 0 && k % 2 != 0) {
            for (int i = n - 1; i >= n - k; i--)
                product *= nums[i];
            return product;
        }

        int i = 0;

        int j = n - 1;
        if (k % 2 != 0) {
            product *= nums[j];
            j--;
            k--;
        }

        k >>= 1;

        for (int l = 0; l < k; l++) {
            int left_product = nums[i] * nums[i + 1];

            int right_product = nums[j] * nums[j - 1];

            if (left_product > right_product) {
                product *= left_product;
                i += 2;
            }
            else {
                product *= right_product;
                j -= 2;
            }
        }

        return product;
    }

	public static int[] computePrefix(int arr[], int n)
	{
		int[] prefix = new int[n];
		prefix[0] = arr[0];
		for(int i = 1;i<n;i++)
		{
			prefix[i] = prefix[i-1]+arr[i];
		}

		return prefix;
	}

	public static int lcm(int a, int b)
	{
		return (a*b)/gcd(a,b);
	}

	public static int phi(int n)  //euler totient function
    {
        int result = 1;
        for (int i = 2; i < n; i++)
            if (gcd(i, n) == 1)
                result++;
        return result;
    }

	public static int check(int n)
	{
		int cl = 0;
		while(n > 0)
		{
			if(n%10 == 8)
			{
				cl++;
				n/=10;
			}
		}

		return cl;
	}

	public static boolean digCheck(int n)
	{
		int cond = 8;
		while(n > 0)
		{
			if(n%10 == cond)
			{
				return true;
			}
			n/=10;
		}
		return false;
	}

	public static void main(String[] args) throws IOException
	{
		Reader sc=new Reader();

		int n = sc.nextInt();
		int m = sc.nextInt();

		int[][] arr = new int[n][m];

		for(int i = 0;i<n;i++)
		{
			for(int j = 0;j<n;j++)
			{
				if(i == j)
				{
					arr[i][j] = m;
				}
				else {
					arr[i][j] = 0;
				}
			}
		}

		for(int i =0;i<n;i++)
		{
			for(int j = 0;j<n;j++)
			{
				System.out.print(arr[i][j]+" ");
			}
			System.out.println();
		}

	}
}


#include <bits/stdc++.h>
#include <conio.h>
#define F first
#define S second
#define pii pair<ll, ll>
#define pb push_back

using namespace std;

typedef long long ll;

int main()
{
    ll n, k;
    cin >> n >> k;
    int a[n][n];
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
        {
            if(i == j)
                a[i][j] = k;
            else
                a[i][j] = 0;
        }
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
            cout << a[i][j] << ' ';
        cout << endl;
    }

    return 0;
}


#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
	int n,k,**a;
	cin>>n>>k;
	a = (int**)malloc(sizeof(int*)*n);
	for(int i=0;i<n;++i)a[i]=(int*)malloc(sizeof(int)*n);
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j)
			a[i][j]=0;
	for(int i=0;i<n;++i)a[i][i]=k;
  //print
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j)
      cout<<a[i][j]<<" ";
    cout<<endl;
  }
	//free
	for(int i=0;i<n;++i)free(a[i]);
	free(a);
	return 0;
}


#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
	int n,k,**a;
	cin>>n>>k;
	a = (int**)malloc(sizeof(int*)*n);
	for(int i=0;i<n;++i)a[i]=(int*)malloc(sizeof(int)*n);
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j)
			a[i][j]=0;
	if(k-(n-1)>0){
		for(int i=0;i<n;++i)a[i][i]=1;
		for(int i=n-1;i>-1;--i)a[n-i-1][i]=k-(n-1);
		for(int i=1;i<n-1;++i){
			a[0][i]=1;a[i][0]=1;
			a[i][n-1]=1;a[n-1][i]=1;
		}
	}else{
		for(int i=0;i<n-(k-n)*-1;++i)
			for(int j=0;j<n-(k-n)*-1;++j)
				a[i][j]=1;
	}
  //print
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j)
      cout<<a[i][j]<<" ";
    cout<<endl;
  }
	//free
	for(int i=0;i<n;++i)free(a[i]);
	free(a);
	return 0;
}


#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
	int n,k,**a;
	cin>>n>>k;
	a = (int**)malloc(sizeof(int*)*n);
	for(int i=0;i<n;++i)a[i]=(int*)malloc(sizeof(int)*n);
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j)
			a[i][j]=0;
	if(k-(n-1)>0){
		for(int i=0;i<n;++i)a[i][i]=1;
		for(int i=n-1;i>-1;--i)a[n-i-1][i]=k-(n-1);
		for(int i=1;i<n-1;++i){
			a[0][i]=1;a[i][0]=1;
			a[i][n-1]=1;a[n-1][i]=1;
		}
	}else{
		for(int i=0;i<n;++i)
			a[i][i]=k;
	}
  //print
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j)
      cout<<a[i][j]<<" ";
    cout<<endl;
  }
	//free
	for(int i=0;i<n;++i)free(a[i]);
	free(a);
	return 0;
}


#include <iostream>
using namespace std;

int main(){
    int a, b, x, y, q=0;
    cin>> a >> b;
    int arr[a][a]={0};
    if(a>b){
        for(int i=0; i<a; i++){
            for(int j=0; j<a; j++){
                arr[i][j]=0;
                if(i==j)
                arr[i][j]=b;
            }
            cout << endl;
        }
    }
    else{
        x=b/a;
        y=x;
        if(b%a!=0){
            x++;
        }
        for(int i=0; i<a; i++){
            for(int j=0; j<a; j++){
                if(j==q){
                    arr[i][j]=y;
                }
                else{
                    arr[i][j]=x;
                }
            }
            q++;
        }
    }
    for(int i=0; i<a; i++){
        for(int j=0; j<a; j++){
            cout << arr[i][j] << " ";
        }
        cout << endl;
    }
}


#include <iostream>
using namespace std;

int main(){
    int a, b, x, y, q=0;
    cin>> a >> b;
    int arr[a][a];
    x=b/a;
    y=x;
    if(b%a!=0){
        x++;
    }
    for(int i=0; i<a; i++){
        for(int j=0; j<a; j++){
            if(j==q){
                arr[i][j]=y;
            }
            else{
                arr[i][j]=x;
            }
        }
        q++;
    }
    for(int i=0; i<a; i++){
        for(int j=0; j<a; j++){
            cout << arr[i][j] << " ";
        }
        cout << endl;
    }
}


#include <iostream>
using namespace std;

int main(){
    int a, b, x, y, q=0;
    cin>> a >> b;
    int arr[a][a]={0};
    if(a>b){
        for(int i=0; i<a; i++){
            for(int j=0; j<a; j++){
                arr[i][j]=0;
                if(i==j)
                arr[i][j]=b;
            }
        }
    }
    else{
        x=b/a;
        y=x;
        if(b%a!=0){
            y=a-(b%a);
        }
        for(int i=0; i<a; i++){
            for(int j=0; j<a; j++){
                if(j==q){
                    arr[i][j]=y;
                }
                else{
                    arr[i][j]=x;
                }
            }
            q++;
        }
    }
    for(int i=0; i<a; i++){
        for(int j=0; j<a; j++){
            cout << arr[i][j] << " ";
        }
        cout << endl;
    }
}


#include <iostream>
using namespace std;

int main(){
    int a, b, x, y, q=0;
    cin>> a >> b;
    int arr[a][a]={0};
    if(a>b){
        for(int i=0; i<a; i++){
            for(int j=0; j<a; j++){
                arr[i][j]=0;
                if(i==j)
                arr[i][j]=b;
            }
            cout << endl;
        }
    }
    else{
        x=b/a;
        y=x;
        if(b%a!=0){
            y=b%a;
            x++;
        }
        for(int i=0; i<a; i++){
            for(int j=0; j<a; j++){
                if(j==q){
                    arr[i][j]=y;
                }
                else{
                    arr[i][j]=x;
                }
            }
            q++;
        }
    }
    for(int i=0; i<a; i++){
        for(int j=0; j<a; j++){
            cout << arr[i][j] << " ";
        }
        cout << endl;
    }
}


#include <iostream>
using namespace std;

int main(){
    int a, b, x, y, q=0;
    cin>> a >> b;
    int arr[a][a];
    for(int i=0; i<a; i++){
        for(int j=0; j<a; j++){
            arr[i][j]=0;
            if(i==j){
                cout << b << " ";
            }
            cout << 0 << " "
        }
        cout << endl;
    }
}


#include <iostream>
using namespace std;

int main(){
    int a, b;
    cin>> a >> b;
    int arr[a][a];
    for(int i=0; i<a; i++){
        for(int j=0; j<a; j++){
            arr[i][j]=0;
            if(i==j){
                cout << b << " ";
            }
            cout << 0 << " ";
        }
        cout << endl;
    }
}


#include <iostream>
using namespace std;

int main(){
    int a, b;
    cin>> a >> b;
    int arr[a][a];
    for(int i=0; i<a; i++){
        for(int j=0; j<a; j++){
            arr[i][j]=0;
            if(i==j){
                cout << b << " ";
            }
            else
                cout << 0 << " ";
        }
        cout << endl;
    }
}


#include <iostream>
using namespace std;

int main(){
    int a, b, x, y, q=0;
    cin>> a >> b;
    int arr[a][a]={0};
    if(a>b){
        for(int i=0; i<a; i++){
            for(int j=0; j<a; j++){
                arr[i][j]=0;
                if(i==j)
                arr[i][j]=b;
            }
            cout << endl;
        }
    }
    else{
        x=b/a;
        y=x;
        if(b%a!=0){
            y=a-(b%a);
            x++;
        }
        for(int i=0; i<a; i++){
            for(int j=0; j<a; j++){
                if(j==q){
                    arr[i][j]=y;
                }
                else{
                    arr[i][j]=x;
                }
            }
            q++;
        }
    }
    for(int i=0; i<a; i++){
        for(int j=0; j<a; j++){
            cout << arr[i][j] << " ";
        }
        cout << endl;
    }
}


#include <iostream>
using namespace std;

int main(){
    int a, b, x, y, q=0;
    cin>> a >> b;
    int arr[a][a]={0};
    if(a>b){
        for(int i=0; i<a; i++){
            for(int j=0; j<a; j++){
                arr[i][j]=0;
                if(i==j)
                arr[i][j]=b;
            }
        }
    }
    else{
        x=b/a;
        y=x;
        if(b%a!=0){
            y=(b%a);
        }
        for(int i=0; i<a; i++){
            for(int j=0; j<a; j++){
                if(j==q){
                    arr[i][j]=y;
                }
                else{
                    arr[i][j]=x;
                }
            }
            q++;
        }
    }
    for(int i=0; i<a; i++){
        for(int j=0; j<a; j++){
            cout << arr[i][j] << " ";
        }
        cout << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define sf scanf
#define pf printf

int main()
{
    ll i,j,n,k,sum=0;
    cin>>n>>k;
    vector<ll>vv;
    for(i=0; i<1; i++)
    {
        for(j=0; j<n-1; j++)
        {
            vv.push_back(1);
        }
        vv.push_back(k-j);
    }

    for(i=0; i<n; i++)
    {
        if(i%2==0)
        {
            for(j=n-1; j>0; j--)
            {
                cout<<vv[j]<<" ";
            }
            cout<<vv[j]<<endl;
        }
        else
        {
            for(j=0; j<n-1; j++)
            {
                cout<<vv[j]<<" ";
            }
            cout<<vv[j]<<endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define sf scanf
#define pf printf

int main()
{
    ll i,j,n,k,sum=0;
    cin>>n>>k;

    for(i=0; i<n; i++)
    {
        for(int l=0;l<i;l++)
            cout<<0<<" ";
        cout<<k;
        for(j=i+1; j<n; j++)
        {
            cout<<" 0";
        }
        cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define sf scanf
#define pf printf

int main()
{
    ll i,j,n,k,sum=0;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        for(j=0;j<n-1;j++)
        {
            cout<<1<<" ";
        }
        cout<<k-j<<endl;
    }
    return 0;
}


#include<iostream>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j){
                a[i][j] = k;
            }
            else{
                a[i][j] = 0;
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


#include<iostream>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j){
                a[i][j] = k;
            }
            else{
                a[i][j] = 0;
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<a[i][j];
        }
        cout<<endl;
    }
    return 0;
}


#include<iostream>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j){
                a[i][j] = k;
            }
            else{
                a[i][j] = 0;
            }
        }
    }
    for(int i=0;i<n;;i++){
        for(int j=0;i<n;j++){
            cout<<a[i][j];
        }
        cout<<endl;
    }
    return 0;
}


#include<iostream>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j){
                a[i][j] = k;
            }
            else{
                a[i][j] = 0;
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;i<n;j++){
            cout<<a[i][j];
        }
        cout<<endl;
    }
    return 0;
}


#include<iostream>
  #include<math.h>
  #include<cstring>
                      //  #include<queue>

    //#include<vector>
 #include<algorithm>
using namespace std;
#define endl "\n"
#define ll long long
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
int main()
{  IOS;

int n,k;
cin>>n>>k;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
cout<<(i==j?k:0)<<" ";

    cout<<endl;
}

}


#include<iostream>
  #include<math.h>
  #include<cstring>
                      //  #include<queue>

    //#include<vector>
 #include<algorithm>
using namespace std;
#define endl "\n"
#define ll long long
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
int main()
{  IOS;

int n,k;
cin>>n>>k;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
cout<<(i==j?k:0);

    cout<<endl;
}

}


#include<iostream>
  #include<math.h>
  #include<cstring>
                      //  #include<queue>

    //#include<vector>
 #include<algorithm>
using namespace std;
#define endl "\n"
#define ll long long
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
int main()
{  IOS;

int n,k;
cin>>n>>k;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
cout<<(i==j?k:0);
}


#include<bits/stdc++.h>
using namespace std;
/* علي الطلاق لتوكلو
     🍦🍨🍳🍧🍔🍔
     🍗🍗🍗🍗🍔🍔🍔🍔 */
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define all(v) ((v).begin()), ((v).end())
#define ll long long
#define sf(a) scanf("%d", &a)
#define forn(i,n) for(int i = 0; i < n; ++i)

/*long long fact(long long n) {
   if ((n==0)||(n==1))
      return 1;
   else
      return n*fact(n-1);
}*/
/*int binarySearch(int arr[], int p, int r, int num) {
   if (p <= r) {
      int mid = (p + r)/2;
      if (arr[mid] == num)
         return mid ;
      if (arr[mid] > num)
         return binarySearch(arr, p, mid-1, num);
      if (arr[mid] > num)
         return binarySearch(arr, mid+1, r, num);
   }
   return -1;
}*/
/* if prime*/
/* bool arr[N];
arr[0]=arr[1]=false;
for(int i=2;i<=N;i++){
    arr[i]=true;
}
for(int i=2;i*i<N;i++){
    if(arr[i]){
        for(int j=i*i;j<=N;j+=i){
            arr[j]=false;
        }
    }

} */
/*int checkifexisted(ll a){
    if(a<0) a= -a;
 while(a){
            if(a%10==8) {
                return 1;
            }
            a/=10;
        }
        return 0;
}*/
/*long long gcd( int a,int b){
return (b==0?a:gcd(b,a%b));
}*/
/*long long fastbowerMOD(long long x,long long p , long long m){
if (p==1) return x;
if(p%2==0)
  return (fastbowerMOD((x%m*x%m),p/2,m)%m);
else
  return ((fastbowerMOD((x%m*x%m),p/2,m)%m)*(x%m))%m;
}*/
//A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
// E 5 / 14 N 15 O 18 R 26 Z
/*long long power(long long x,long long y){
if (y==1) return x;
else if(y%2==0)
    return power( x*x,y/2 );
    else return power(x*x,y/2)*x;
*/

int main(){
int n,k; scanf("%d%d",&n,&k); int arr[n][n]={};
for(int i=0;i<n;i++){
  for(int j=0;j<n;j++){
        if(i==0 ) arr[i][j]=k;
  }
}
for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
        cout<<arr[i][j]<<" ";
    } cout<<endl;
}
return 0;}


#include<bits/stdc++.h>
using namespace std;
/* علي الطلاق لتوكلو
     🍦🍨🍳🍧🍔🍔
     🍗🍗🍗🍗🍔🍔🍔🍔 */
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define all(v) ((v).begin()), ((v).end())
#define ll long long
#define sf(a) scanf("%d", &a)
#define forn(i,n) for(int i = 0; i < n; ++i)

/*long long fact(long long n) {
   if ((n==0)||(n==1))
      return 1;
   else
      return n*fact(n-1);
}*/
/*int binarySearch(int arr[], int p, int r, int num) {
   if (p <= r) {
      int mid = (p + r)/2;
      if (arr[mid] == num)
         return mid ;
      if (arr[mid] > num)
         return binarySearch(arr, p, mid-1, num);
      if (arr[mid] > num)
         return binarySearch(arr, mid+1, r, num);
   }
   return -1;
}*/
/* if prime*/
/* bool arr[N];
arr[0]=arr[1]=false;
for(int i=2;i<=N;i++){
    arr[i]=true;
}
for(int i=2;i*i<N;i++){
    if(arr[i]){
        for(int j=i*i;j<=N;j+=i){
            arr[j]=false;
        }
    }

} */
/*int checkifexisted(ll a){
    if(a<0) a= -a;
 while(a){
            if(a%10==8) {
                return 1;
            }
            a/=10;
        }
        return 0;
}*/
/*long long gcd( int a,int b){
return (b==0?a:gcd(b,a%b));
}*/
/*long long fastbowerMOD(long long x,long long p , long long m){
if (p==1) return x;
if(p%2==0)
  return (fastbowerMOD((x%m*x%m),p/2,m)%m);
else
  return ((fastbowerMOD((x%m*x%m),p/2,m)%m)*(x%m))%m;
}*/
//A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
// E 5 / 14 N 15 O 18 R 26 Z
/*long long power(long long x,long long y){
if (y==1) return x;
else if(y%2==0)
    return power( x*x,y/2 );
    else return power(x*x,y/2)*x;
*/

int main(){
int n,k; scanf("%d%d",&n,&k);
for(int i=0;i<n;i++){
    cout<<k<<" ";
    for(int j=1;j<n;j++){
        cout<<'0'<<" ";
    } cout<<endl;
}
return 0;}


#include<bits/stdc++.h>
using namespace std;
/* علي الطلاق لتوكلو
     🍦🍨🍳🍧🍔🍔
     🍗🍗🍗🍗🍔🍔🍔🍔 */
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define all(v) ((v).begin()), ((v).end())
#define ll long long
#define sf(a) scanf("%d", &a)
#define forn(i,n) for(int i = 0; i < n; ++i)

/*long long fact(long long n) {
   if ((n==0)||(n==1))
      return 1;
   else
      return n*fact(n-1);
}*/
/*int binarySearch(int arr[], int p, int r, int num) {
   if (p <= r) {
      int mid = (p + r)/2;
      if (arr[mid] == num)
         return mid ;
      if (arr[mid] > num)
         return binarySearch(arr, p, mid-1, num);
      if (arr[mid] > num)
         return binarySearch(arr, mid+1, r, num);
   }
   return -1;
}*/
/* if prime*/
/* bool arr[N];
arr[0]=arr[1]=false;
for(int i=2;i<=N;i++){
    arr[i]=true;
}
for(int i=2;i*i<N;i++){
    if(arr[i]){
        for(int j=i*i;j<=N;j+=i){
            arr[j]=false;
        }
    }

} */
/*int checkifexisted(ll a){
    if(a<0) a= -a;
 while(a){
            if(a%10==8) {
                return 1;
            }
            a/=10;
        }
        return 0;
}*/
/*long long gcd( int a,int b){
return (b==0?a:gcd(b,a%b));
}*/
/*long long fastbowerMOD(long long x,long long p , long long m){
if (p==1) return x;
if(p%2==0)
  return (fastbowerMOD((x%m*x%m),p/2,m)%m);
else
  return ((fastbowerMOD((x%m*x%m),p/2,m)%m)*(x%m))%m;
}*/
//A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
// E 5 / 14 N 15 O 18 R 26 Z
/*long long power(long long x,long long y){
if (y==1) return x;
else if(y%2==0)
    return power( x*x,y/2 );
    else return power(x*x,y/2)*x;
*/

int main(){
int n,k; scanf("%d%d",&n,&k); int arr[n][n]={};
for(int i=0;i<n;i++){
  for(int j=0;j<n;j++){
        if(i==j ) arr[i][j]=k;
  }
}
for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
        cout<<arr[i][j]<<" ";
    } cout<<endl;
}
return 0;}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define se second
#define mp make_pair
#define fi first
#define del(a,vec) vec.erase(std::remove(vec.begin(), vec.end(), a), vec.end());
#define search(f,l,v) binary_search(f,l,v)
#define iter(a,b) vector<int>::iterator a,b
#define lower(v,num) lower_bound (v.begin(), v.end(), num);
#define upper(v,num) upper_bound (v.begin(), v.end(), num);
namespace Rahul{
    bool isPrime(int n)
    {if (n <= 1)  return false; if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true; }
    long int pow(int x,int y,long int z)
    {
        long int res=1;
        while(y>0)
            {
                if(y&1)
                    res=(res*x)%z;
                y=y/2;
                x=(x*x)%z;

            }
            return res;
    }
    long int _gcd(long int a,long int b)
    {
        if(a==0)
            return b;
        else
            return _gcd(b%a,a);
    }
    string deleteit(int i,string s)
    {
        string ans="";
        for(int j=0;j<i;j++)
            {
                ans+=s[j];
            }
        for(int j=i+1;j<s.length();j++)
            {
                ans+=s[j];
            }
        return ans;
    }
    string reverse(string s)
    {
        for(int i=0;i<s.length()/2;i++)
        {
            char temp=s[i];
            s[i]=s[s.length()-i-1];
            s[s.length()-i-1]=temp;
        }
        return s;
    }
};
using namespace Rahul;
int main()
{
     ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
     int n;
     int k;
     cin>>n;
     cin>>k;
     int a[n];
     for(int i=0;i<n;i++)
        {
            a[i]=min(k,2);
           if(i==n-1)
            a[i]=k;
            k=k-2;
        }
     for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
                {
                    cout<<a[(i+j)%n]<<" ";
                }
            cout<<"\n";
        }

    //  int a[n];
    //  unordered_map<int,int>cn;
    //  for(int i=0;i<n;i++)
    //     {
    //         cin>>a[i];
    //         cn[a[i]]++;
    //     }
    // string s="";
    // int flag=0;
    //  while(cn[5]>=9 && cn[0]>=1)
    //         {
    //             // cout<<5555555550;
    //             int val=cn[5]/9;
    //             for(int i=0;i<val;i++)
    //                 {
    //                     s+="555555555";
    //                 }
    //             if(val==1)
    //                 {s=s+'0';
    //                 cn[0]-=1;}

    //             cn[5]-=9*val;

    //             // s+="5555555550";
    //             flag=1;
    //         }
        //     while(cn[0]>0 && flag==1 )
        //      {
        //       s+='0';
        //       cn[0]--;
        //       }
        // if(s.length()>0)
        //     cout<<s<<endl;
        // else if(cn[0]>0)
        //     cout<<0<<endl;
        // else
        //   cout<<-1<<endl;
    //  }
    //  n++;
    //  string s[n+1];

    //  for(int i=0;i<n+1;i++)
    //     {
    //         int k=i+1;
    //         int r=i;
    //         string p="";
    //         while(k--)
    //         {
    //             char l=' ';
    //             p=l+p;
    //             p=char(r+'0')+p;
    //             r--;
    //         }
    //         s[i]=p;
    //         // if(i>1)
    //         // string pp=s[i-1];
    //         // pp=reverse(pp);
    //         // p=s+pp;

    //     }
    // string p[n+1];
    //     p[0]='0';
    //  for(int i=1;i<n;i++)
    //   {
    //     //   char l=' ';
    //       string ps=s[i];
    //       ps=deleteit(ps.length()-1,ps);
    //       p[i]=ps+reverse(s[i-1]);

    //   }

    //   for(int i=0;i<n;i++)
    //     {
    //         string st=p[i];
    //         for(int j=0;j<(n-i-1);j++)
    //             {st=' '+st;
    //             st=' '+st;}
    //         p[i]=st;
    //     }

    //   for(int i=0;i<n;i++)
    //     cout<<p[i]<<endl;
    //   for(int i=n-2;i>=0;i--)
    //     cout<<p[i]<<endl;

        // long int a=55555555500;
        // cout<<a%90<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define se second
#define mp make_pair
#define fi first
#define del(a,vec) vec.erase(std::remove(vec.begin(), vec.end(), a), vec.end());
#define search(f,l,v) binary_search(f,l,v)
#define iter(a,b) vector<int>::iterator a,b
#define lower(v,num) lower_bound (v.begin(), v.end(), num);
#define upper(v,num) upper_bound (v.begin(), v.end(), num);
namespace Rahul{
    bool isPrime(int n)
    {if (n <= 1)  return false; if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true; }
    long int pow(int x,int y,long int z)
    {
        long int res=1;
        while(y>0)
            {
                if(y&1)
                    res=(res*x)%z;
                y=y/2;
                x=(x*x)%z;

            }
            return res;
    }
    long int _gcd(long int a,long int b)
    {
        if(a==0)
            return b;
        else
            return _gcd(b%a,a);
    }
    string deleteit(int i,string s)
    {
        string ans="";
        for(int j=0;j<i;j++)
            {
                ans+=s[j];
            }
        for(int j=i+1;j<s.length();j++)
            {
                ans+=s[j];
            }
        return ans;
    }
    string reverse(string s)
    {
        for(int i=0;i<s.length()/2;i++)
        {
            char temp=s[i];
            s[i]=s[s.length()-i-1];
            s[s.length()-i-1]=temp;
        }
        return s;
    }
};
using namespace Rahul;
int main()
{
     ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
     int n;
     int k;
     cin>>n;
     cin>>k;
     int a[n];
     for(int i=0;i<n-1;i++)
        {
            if(k>=2)
                {
                    a[i]=2;
                    k=k-2;
                }
            else if(k==1)
                a[i]=k--;
            else if(k==0)
                a[i]=0;

        //     a[i]=min(k,2);
        //   if(i==n-1)
        //     a[i]=k;
        //     k=k-2;
        }
        a[n-1]=k;
     for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
                {
                    cout<<a[(i+j)%n]<<" ";
                }
            cout<<"\n";
        }

    //  int a[n];
    //  unordered_map<int,int>cn;
    //  for(int i=0;i<n;i++)
    //     {
    //         cin>>a[i];
    //         cn[a[i]]++;
    //     }
    // string s="";
    // int flag=0;
    //  while(cn[5]>=9 && cn[0]>=1)
    //         {
    //             // cout<<5555555550;
    //             int val=cn[5]/9;
    //             for(int i=0;i<val;i++)
    //                 {
    //                     s+="555555555";
    //                 }
    //             if(val==1)
    //                 {s=s+'0';
    //                 cn[0]-=1;}

    //             cn[5]-=9*val;

    //             // s+="5555555550";
    //             flag=1;
    //         }
        //     while(cn[0]>0 && flag==1 )
        //      {
        //       s+='0';
        //       cn[0]--;
        //       }
        // if(s.length()>0)
        //     cout<<s<<endl;
        // else if(cn[0]>0)
        //     cout<<0<<endl;
        // else
        //   cout<<-1<<endl;
    //  }
    //  n++;
    //  string s[n+1];

    //  for(int i=0;i<n+1;i++)
    //     {
    //         int k=i+1;
    //         int r=i;
    //         string p="";
    //         while(k--)
    //         {
    //             char l=' ';
    //             p=l+p;
    //             p=char(r+'0')+p;
    //             r--;
    //         }
    //         s[i]=p;
    //         // if(i>1)
    //         // string pp=s[i-1];
    //         // pp=reverse(pp);
    //         // p=s+pp;

    //     }
    // string p[n+1];
    //     p[0]='0';
    //  for(int i=1;i<n;i++)
    //   {
    //     //   char l=' ';
    //       string ps=s[i];
    //       ps=deleteit(ps.length()-1,ps);
    //       p[i]=ps+reverse(s[i-1]);

    //   }

    //   for(int i=0;i<n;i++)
    //     {
    //         string st=p[i];
    //         for(int j=0;j<(n-i-1);j++)
    //             {st=' '+st;
    //             st=' '+st;}
    //         p[i]=st;
    //     }

    //   for(int i=0;i<n;i++)
    //     cout<<p[i]<<endl;
    //   for(int i=n-2;i>=0;i--)
    //     cout<<p[i]<<endl;

        // long int a=55555555500;
        // cout<<a%90<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define se second
#define mp make_pair
#define fi first
#define del(a,vec) vec.erase(std::remove(vec.begin(), vec.end(), a), vec.end());
#define search(f,l,v) binary_search(f,l,v)
#define iter(a,b) vector<int>::iterator a,b
#define lower(v,num) lower_bound (v.begin(), v.end(), num);
#define upper(v,num) upper_bound (v.begin(), v.end(), num);
namespace Rahul{
    bool isPrime(int n)
    {if (n <= 1)  return false; if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true; }
    long int pow(int x,int y,long int z)
    {
        long int res=1;
        while(y>0)
            {
                if(y&1)
                    res=(res*x)%z;
                y=y/2;
                x=(x*x)%z;

            }
            return res;
    }
    long int _gcd(long int a,long int b)
    {
        if(a==0)
            return b;
        else
            return _gcd(b%a,a);
    }
    string deleteit(int i,string s)
    {
        string ans="";
        for(int j=0;j<i;j++)
            {
                ans+=s[j];
            }
        for(int j=i+1;j<s.length();j++)
            {
                ans+=s[j];
            }
        return ans;
    }
    string reverse(string s)
    {
        for(int i=0;i<s.length()/2;i++)
        {
            char temp=s[i];
            s[i]=s[s.length()-i-1];
            s[s.length()-i-1]=temp;
        }
        return s;
    }
};
using namespace Rahul;
int main()
{
     ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
     int n;
     int k;
     cin>>n;
     cin>>k;
     int a[n];
     for(int i=0;i<n-1;i++)
        {
            if(k>2)
                {
                    a[i]=2;
                    k=k-2;
                }
            else if(k==1)
                a[i]=k--;
            else if(k==0)
                a[i]=0;

        //     a[i]=min(k,2);
        //   if(i==n-1)
        //     a[i]=k;
        //     k=k-2;
        }
        a[n-1]=k;
     for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
                {
                    cout<<a[(i+j)%n]<<" ";
                }
            cout<<"\n";
        }

    //  int a[n];
    //  unordered_map<int,int>cn;
    //  for(int i=0;i<n;i++)
    //     {
    //         cin>>a[i];
    //         cn[a[i]]++;
    //     }
    // string s="";
    // int flag=0;
    //  while(cn[5]>=9 && cn[0]>=1)
    //         {
    //             // cout<<5555555550;
    //             int val=cn[5]/9;
    //             for(int i=0;i<val;i++)
    //                 {
    //                     s+="555555555";
    //                 }
    //             if(val==1)
    //                 {s=s+'0';
    //                 cn[0]-=1;}

    //             cn[5]-=9*val;

    //             // s+="5555555550";
    //             flag=1;
    //         }
        //     while(cn[0]>0 && flag==1 )
        //      {
        //       s+='0';
        //       cn[0]--;
        //       }
        // if(s.length()>0)
        //     cout<<s<<endl;
        // else if(cn[0]>0)
        //     cout<<0<<endl;
        // else
        //   cout<<-1<<endl;
    //  }
    //  n++;
    //  string s[n+1];

    //  for(int i=0;i<n+1;i++)
    //     {
    //         int k=i+1;
    //         int r=i;
    //         string p="";
    //         while(k--)
    //         {
    //             char l=' ';
    //             p=l+p;
    //             p=char(r+'0')+p;
    //             r--;
    //         }
    //         s[i]=p;
    //         // if(i>1)
    //         // string pp=s[i-1];
    //         // pp=reverse(pp);
    //         // p=s+pp;

    //     }
    // string p[n+1];
    //     p[0]='0';
    //  for(int i=1;i<n;i++)
    //   {
    //     //   char l=' ';
    //       string ps=s[i];
    //       ps=deleteit(ps.length()-1,ps);
    //       p[i]=ps+reverse(s[i-1]);

    //   }

    //   for(int i=0;i<n;i++)
    //     {
    //         string st=p[i];
    //         for(int j=0;j<(n-i-1);j++)
    //             {st=' '+st;
    //             st=' '+st;}
    //         p[i]=st;
    //     }

    //   for(int i=0;i<n;i++)
    //     cout<<p[i]<<endl;
    //   for(int i=n-2;i>=0;i--)
    //     cout<<p[i]<<endl;

        // long int a=55555555500;
        // cout<<a%90<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define mx 100002
#define ss second
#define ff first
#define ll int

ll a[mx];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n;
    cin>>n;
    int k;
    cin>>k;
    int x=k-n+1;
    int y=1;
    if(x<0) {
        y=0;
        x=n;
    }

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j) cout<<x<<" ";
            else cout<<y<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define mx 100002
#define ss second
#define ff first
#define ll int

ll a[mx];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n;
    cin>>n;
    int k;
    cin>>k;
    int x=k-n+1;
    int y=1;
    if(x<0) {
        y=0;
        x=k;
    }

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j) cout<<x<<" ";
            else cout<<y<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define mx 100002
#define ss second
#define ff first
#define ll int

ll a[mx];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n;
    cin>>n;
    int k;
    cin>>k;
    int x=k-n+1;
    int y=1;
    if(x<0) y=0;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j) cout<<x<<" ";
            else cout<<y<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;

#define ll                      long long
#define ul                      unsigned long
#define ull                     unsigned long long
#define REP(i, a, b)            for (int i=a; i<=b; i++)
#define vll                     vector<ll>
#define vl                      vector<l>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define mii                     map<int,int>
#define mci                     map<char,int>
#define vpii                    vector< pair <int,int> >
#define pii                     pair <int,int>

int INF = 1000000005;
long long INFF = 1000000000000000005LL;
int dirx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8] = { 0, 1, -1, 0, -1, 1, -1, 1 };
double pi = 3.1415926536;
int MOD = 1e9 + 7;

ll power(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1)res = res * x;
		x = (x * x);
		n /= 2;
	}
	return res;
}

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("error.txt", "w", stderr);
	freopen("output.txt", "w", stdout);
#endif

	ios::sync_with_stdio(false);
	cin.tie();
	cout.tie();

	int  n, k, c = 0, sum = 0;
	cin >> n >> k;
	int a[n][n];
	int j = 0;
	REP(l, 0, n - 1) {
		if (l == n - 1) {
			c = k;
		}
		int p1 = 0, p2 = j++;
		REP(m, 0, n - 1) {
			a[p1 % n][p2 % n] = c;
			p1++;
			p2++;
		}

	}
	REP(i, 0, n - 1) {
		REP(j, 0, n - 1) {
			cout << a[i][j] << ' ';
		}
		cout << '\n';
	}

}


#include<bits/stdc++.h>
using namespace std;

#define ll                      long long
#define ul                      unsigned long
#define ull                     unsigned long long
#define REP(i, a, b)            for (int i=a; i<=b; i++)
#define vll                     vector<ll>
#define vl                      vector<l>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define mii                     map<int,int>
#define mci                     map<char,int>
#define vpii                    vector< pair <int,int> >
#define pii                     pair <int,int>

int INF = 1000000005;
long long INFF = 1000000000000000005LL;
int dirx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8] = { 0, 1, -1, 0, -1, 1, -1, 1 };
double pi = 3.1415926536;
int MOD = 1e9 + 7;

ll power(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1)res = res * x;
		x = (x * x);
		n /= 2;
	}
	return res;
}

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("error.txt", "w", stderr);
	freopen("output.txt", "w", stdout);
#endif

	ios::sync_with_stdio(false);
	cin.tie();
	cout.tie();

	int  n, k, c = 0, sum = 0;
	cin >> n >> k;
	int a[n][n];
	int j = 0;
	REP(l, 0, n - 1) {
		if (l == n - 1) {
			c = k - sum;
		}
		int p1 = 0, p2 = j++;
		REP(m, 0, n - 1) {
			a[p1 % n][p2 % n] = c;
			p1++;
			p2++;
		}

		sum += c++;
	}
	REP(i, 0, n - 1) {
		REP(j, 0, n - 1) {
			cout << a[i][j] << ' ';
		}
		cout << '\n';
	}

}


#include<bits/stdc++.h>
using namespace std;
#define fr(i,n) for(int i=0;i<n;i++)
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    int div=k/n;
    int rem=k-div*n;
    fr(i,n)
    {
        fr(j,n)
        {
            if(j==n-i-1 && rem>0)
                cout<<rem+div<<" ";
            else
                cout<<div<<" ";
        }
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define fr(i,n) for(int i=0;i<n;i++)
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    int div=k/n;
    int rem=k-div*n;
    fr(i,n)
    {
        fr(j,n)
        {
            if(j==n-i-1 && rem>0)
                cout<<rem<<" ";
            else
                cout<<div<<" ";
        }
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define fr(i,n) for(int i=0;i<n;i++)
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    int div=k/n;
    int rem=k-div*n;
    fr(i,n)
    {
        fr(j,n)
        {
            if(j==n-i-1)
                cout<<rem<<" ";
            else
                cout<<div<<" ";
        }
        cout<<endl;
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);

		int n = in.nextInt();
		int sz = in.nextInt();
		sz *= 8;
		int[] a = new int[n];

		for(int i = 0; i < n; i++)
		{
			a[i] = in.nextInt();
		}

		Arrays.sort(a);
		int k = sz / n;
		int values = (k < 30 ? (1 << k) : n);
		int ans = 0;
		int r = 0;
		int diff = 0;
		for(int i = 0; i < n; i++)
		{
			while(r < n)
			{
				if(r > i && a[r] == a[r - 1])
				{
					r++;
				}
				else
				{
					if(diff == values)
					{
						break;
					}
					diff++;
					r++;
				}
			}

			ans = Math.max(ans, r - i);
			if(i < n - 1 && (i + 1 == r || a[i] != a[i + 1]))
			{
				diff--;
			}
		}

		out.println(n - ans);

		out.close();
	}

	static class InputReader
	{
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream)
		{
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next()
		{
			while(tokenizer == null || !tokenizer.hasMoreTokens())
			{
				try
				{
					tokenizer = new StringTokenizer(reader.readLine());
				}
				catch(IOException e)
				{
					throw new RuntimeException(e);
				}
			}

			return tokenizer.nextToken();
		}

		public int nextInt()
		{
			return Integer.parseInt(next());
		}

		public long nextLong()
		{
			return Long.parseLong(next());
		}
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	static double log2(double num)
	{
		return (Math.log(num) / Math.log(2));
	}

	public static void main (String[] args) throws java.lang.Exception
	{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);

		long N = in.nextLong();
		long I = in.nextLong();
		long[] arr = new long[(int)N];
		Set<Long> st = new HashSet<Long>();

		for(int i = 0; i < N; i++)
		{
			arr[i] = in.nextLong();
			st.add(arr[i]);
		}

		long sz = st.size();
		long k;
		if(sz % 2 == 0)
			k = (long)log2(sz);
		else
			k = (long)log2(sz) + 1;

		long res = N * k;
		if(res <= I * 8)
		{
			out.println("0");
			out.close();
			return;
		}

		out.println((long)log2(res - I * 8));
		out.close();
	}

	static class InputReader
	{
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream)
		{
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next()
		{
			while(tokenizer == null || !tokenizer.hasMoreTokens())
			{
				try
				{
					tokenizer = new StringTokenizer(reader.readLine());
				}
				catch(IOException e)
				{
					throw new RuntimeException(e);
				}
			}

			return tokenizer.nextToken();
		}

		public int nextInt()
		{
			return Integer.parseInt(next());
		}

		public long nextLong()
		{
			return Long.parseLong(next());
		}

		public double nextDouble()
		{
			return Double.parseDouble(next());
		}
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);

		int n = in.nextInt();
		int sz = in.nextInt();
		sz *= 8;
		ArrayList<Integer> a = new ArrayList<Integer>();

		for(int i = 0; i < n; i++)
		{
			a.add(in.nextInt());
		}

		Collections.sort(a);
		int k = sz / n;
		int values = (k < 30 ? (1 << k) : n);
		int ans = 0;
		int r = 0;
		int diff = 0;
		for(int i = 0; i < n; i++)
		{
			while(r < n)
			{
				if(r > i && a.get(r) == a.get(r - 1))
				{
					r++;
				}
				else
				{
					if(diff == values)
					{
						break;
					}
					diff++;
					r++;
				}
			}

			ans = Math.max(ans, r - i);
			if(i < n - 1 && (i + 1 == r || a.get(i) != a.get(i + 1)))
			{
				diff--;
			}
		}

		out.println(n - ans);

		out.close();
	}

	static class InputReader
	{
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream)
		{
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next()
		{
			while(tokenizer == null || !tokenizer.hasMoreTokens())
			{
				try
				{
					tokenizer = new StringTokenizer(reader.readLine());
				}
				catch(IOException e)
				{
					throw new RuntimeException(e);
				}
			}

			return tokenizer.nextToken();
		}

		public int nextInt()
		{
			return Integer.parseInt(next());
		}

		public long nextLong()
		{
			return Long.parseLong(next());
		}
	}
}


/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fucking interest
*******************************
Higher, higher, even higher, to the point you won’t even be able to see me
https://www.a2oj.com/Ladder16.html
*******************************
NEVER DO 300IQ CONTESTS EVER
300IQ AS WRITER = EXTRA NONO
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class x1198A
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int I = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         int k = 1;
         for(; k <= N; k++)
            if((long)N*Math.ceil(Math.log(k)/Math.log(2)) > 8*I)
               break;
         k--;
         //compress
         sort(arr);
         HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
         int boof = 0;
         for(int x: arr)
            if(!map.containsKey(x))
               map.put(x, boof++);
         int[] freq = new int[boof];
         for(int x: arr)
            freq[map.get(x)]++;
         int res = N;
         if(boof <= k)
            System.out.println(0);
         else
         {
            int sum = 0;
            for(int i=0; i < k; i++)
               sum += freq[i];
            res = Math.min(res, N-sum);
            for(int i=k; i < boof; i++)
            {
               sum += freq[i]-freq[i-k];
               res = Math.min(res, N-sum);
            }
            System.out.println(res);
         }
      }
      public static void sort(int[] arr)
      {
         //stable heap sort
         PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
         for(int a: arr)
            pq.add(a);
         for(int i=0; i < arr.length; i++)
            arr[i] = pq.poll();
      }
   }


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class Main {

	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}

	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    public static long mod = (long) (1e9+7);
    public final static int MAX = (int) 90000000;
   //Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {

		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int I = 8*sc.nextInt();
		int[] a = new int[n];
		TreeMap<Integer,Integer> map = new TreeMap<>();
		for(int i=0;i<n;++i) {
			a[i] = sc.nextInt();
			add(map,a[i]);
		}
		int k = I/n;

		int K = Math.min(n,1<<Math.min(30, k));
		List<Integer> list = new ArrayList<>();
		for(int x : map.keySet())
			list.add(map.get(x));
		int window = 0;
		for(int i=0;i<Math.min(K, list.size());++i) {
			window+=list.get(i);
		}
		int ans = n-window;
		for(int i=K;i<list.size();++i) {
			ans = Math.min(ans,n-window);
			window+=list.get(i);
			window-=list.get(i-K);
		}
		out.println(ans);

		out.close();
		}

	private static void add(Map<Integer, Integer> map, int i) {
		// TODO Auto-generated method stub
		if(map.containsKey(i)) map.put(i, map.get(i)+1);
		else map.put(i, 1);

	}
}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class Main {

	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}

	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    public static long mod = (long) (1e9+7);
    public final static int MAX = (int) 90000000;
   //Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {

		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int I = 8*sc.nextInt();
		int[] a = new int[n];
		TreeMap<Integer,Integer> map = new TreeMap<>();
		for(int i=0;i<n;++i) {
			a[i] = sc.nextInt();
			add(map,a[i]);
		}
		int k = I/n;
		int K = Math.min(n,1<<Math.min(31, k)-1);
		List<Integer> list = new ArrayList<>();
		for(int x : map.keySet())
			list.add(map.get(x));
		int window = 0;
		for(int i=0;i<Math.min(K, list.size());++i) {
			window+=list.get(i);
		}
		int ans = n-window;
		for(int i=K;i<list.size();++i) {
			ans = Math.min(ans,n-window);
			window+=list.get(i);
			window-=list.get(i-K);
		}
		out.println(ans);

		out.close();
		}

	private static void add(Map<Integer, Integer> map, int i) {
		// TODO Auto-generated method stub
		if(map.containsKey(i)) map.put(i, map.get(i)+1);
		else map.put(i, 1);

	}
}


import java.util.*;
import java.io.*;

public class mp3 {

	public static void main (String [] args) throws Exception {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	    StringTokenizer st = new StringTokenizer(f.readLine());
	    long N = Integer.parseInt(st.nextToken());
	    long I = Integer.parseInt(st.nextToken()) * 8;

	    st = new StringTokenizer(f.readLine());
	    TreeMap<Integer, Integer> map = new TreeMap<>();
	    for(long i = 0; i < N; i++) {
	    	int X = Integer.parseInt(st.nextToken());
	    	if(map.containsKey(X)) {
	    		map.put(X, map.get(X)+1);
	    	} else {
	    		map.put(X, 1);
	    	}
	    }

	    //System.out.println(map);

	    int leftKey = map.firstKey(), rightKey = map.lastKey();

	    long numChanged = 0;
	    long necessary = (long)Math.floor(Math.pow(2, I / N));
	    while(map.size() > necessary) {
	    	numChanged += Math.min(map.get(leftKey), map.get(rightKey));
	    	if(map.get(leftKey) > map.get(rightKey)) {
	    		int T = map.lowerKey(rightKey);
	    		map.remove(rightKey);
	    		rightKey = T;
	    	} else {
	    		int T = map.higherKey(leftKey);
	    		map.remove(leftKey);
	    		leftKey = T;
	    	}
	    }

	    out.println(numChanged);
	    out.close();
	    f.close();

	}

}
/*
import java.util.*;
import java.io.*;

public class mp3 {

	public static void main (String [] args) throws Exception {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	    StringTokenizer st = new StringTokenizer(f.readLine());
	    long N = Integer.parseInt(st.nextToken());
	    long I = Integer.parseInt(st.nextToken()) * 8;

	    st = new StringTokenizer(f.readLine());
	    TreeMap<Integer, Integer> map = new TreeMap<>();
	    for(long i = 0; i < N; i++) {
	    	int X = Integer.parseInt(st.nextToken());
	    	if(map.containsKey(X)) {
	    		map.put(X, map.get(X)+1);
	    	} else {
	    		map.put(X, 1);
	    	}
	    }

	    //System.out.println(map);

	    int leftKey = map.firstKey(), rightKey = map.lastKey();

	    long numChanged = 0;
	    long size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2));
	    while(size > I) {
	    	numChanged += Math.min(map.get(leftKey), map.get(rightKey));
	    	if(map.get(leftKey) > map.get(rightKey)) {
	    		int T = map.lowerKey(rightKey);
	    		map.remove(rightKey);
	    		rightKey = T;
	    	} else {
	    		int T = map.higherKey(leftKey);
	    		map.remove(leftKey);
	    		leftKey = T;
	    	}

	    	size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2));
	    }

	    out.println(numChanged);
	    out.close();
	    f.close();

	}

}
*/


import java.util.*;
import java.io.*;

public class mp3 {
	static int[] occurrences;

	public static void main (String [] args) throws IOException {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(System.out, true);

	    StringTokenizer st =  new StringTokenizer(f.readLine());
	    int n = Integer.parseInt(st.nextToken());
	    int I = Integer.parseInt(st.nextToken()) * 8;

	    occurrences = new int[n + 1];
	    int distinctValues = 0;
	    st = new StringTokenizer(f.readLine());
	    for(int i = 0; i < n; i++) {
	    	int temp = Integer.parseInt(st.nextToken());
	    	if(occurrences[temp] == 0)
	    		distinctValues++;
	    	occurrences[temp]++;
	    }

	    //System.out.println(Arrays.toString(occurrences));

	    int lowerLimit = 0;
	    int upperLimit = n;
	    double nk = n * Math.ceil(Math.log(distinctValues)/Math.log(2));
	    int changedValues = 0;
	    while(nk > I) {
	    	while(occurrences[lowerLimit] == 0)
	    		lowerLimit++;
	    	while(occurrences[upperLimit] == 0)
	    		upperLimit--;
	    	changedValues += Math.min(occurrences[lowerLimit], occurrences[upperLimit]);
	    	distinctValues--;
		    nk = n * Math.ceil(Math.log(distinctValues)/Math.log(2));
		    if(occurrences[lowerLimit] > occurrences[upperLimit])
		    	occurrences[upperLimit] = 0;
		    else
		    	occurrences[lowerLimit] = 0;
	    }

	    //System.out.println(Arrays.toString(occurrences));

	    out.println(changedValues);
	    out.close();

	}

}


import java.util.*;
import java.io.*;
import java.util.concurrent.TimeUnit;

public class mp3 {

	public static void main (String [] args) throws Exception {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	    StringTokenizer st = new StringTokenizer(f.readLine());
	    int N = Integer.parseInt(st.nextToken());
	    int I = Integer.parseInt(st.nextToken()) * 8;

	    st = new StringTokenizer(f.readLine());
	    TreeMap<Integer, Integer> map = new TreeMap<>();
	    for(int i = 0; i < N; i++) {
	    	int X = Integer.parseInt(st.nextToken());
	    	if(map.containsKey(X)) {
	    		map.put(X, map.get(X)+1);
	    	} else {
	    		map.put(X, 1);
	    	}
	    }

	    //System.out.println(map);

	    int leftKey = map.firstKey(), rightKey = map.lastKey();

	    int numChanged = 0;
	    int size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2)-0.00001);
	    while(size > I) {
	    	numChanged += Math.min(map.get(leftKey), map.get(rightKey));
	    	if(map.get(leftKey) > map.get(rightKey)) {
	    		int T = map.lowerKey(rightKey);
	    		map.remove(rightKey);
	    		rightKey = T;
	    	} else {
	    		int T = map.higherKey(leftKey);
	    		map.remove(leftKey);
	    		leftKey = T;
	    	}

	    	size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2)-0.00001);
	    }

	    out.println(numChanged);
	    out.close();
	    f.close();
	}

}


import java.util.*;
import java.io.*;

public class mp3 {
	static Map<Integer, Integer> map = new HashMap<Integer, Integer>();
	static List<Integer> lis = new ArrayList<Integer>();
	public static void main (String [] args) throws IOException {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(System.out, true);

	    StringTokenizer st =  new StringTokenizer(f.readLine());
	    int n = Integer.parseInt(st.nextToken());
	    int I = Integer.parseInt(st.nextToken()) * 8;

	    int distinctValues = 0;
	    st = new StringTokenizer(f.readLine());
	    for(int i = 0; i < n; i++) {
	    	int temp = Integer.parseInt(st.nextToken());
	    	if(!map.containsKey(temp)) {
	    		distinctValues++;
	    		map.put(temp,  1);
	    	} else
	    		map.put(temp, map.get(temp) + 1);
	    }

	    for(int each: map.keySet()) {
	    	lis.add(map.get(each));
	    }
	    Collections.sort(lis);

	    double nk = n * Math.ceil(Math.log(distinctValues)/Math.log(2));
	    int changedValues = 0;
	    int lowerLimit = 0;
	    int upperLimit = lis.size() - 1;
	    while(nk > I) {
	    	changedValues += Math.min(lis.get(lowerLimit), lis.get(upperLimit));
	    	distinctValues--;
		    nk = n * Math.ceil(Math.log(distinctValues)/Math.log(2));
		    if(lis.get(lowerLimit) > lis.get(upperLimit))
		    	upperLimit--;
		    else
		    	lowerLimit++;
	    }

	    out.println(changedValues);
	    out.close();

	}

}


import java.util.*;
import java.io.*;

public class mp3 {

	public static void main (String [] args) throws Exception {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	    StringTokenizer st = new StringTokenizer(f.readLine());
	    long N = Integer.parseInt(st.nextToken());
	    long I = Integer.parseInt(st.nextToken()) * 8;
	    long necessary = (long)Math.floor(Math.pow(2, I / N));
	    //System.out.println(necessary);
	    st = new StringTokenizer(f.readLine());
	    TreeMap<Integer, Integer> map = new TreeMap<>();
	    for(long i = 0; i < N; i++) {
	    	int X = Integer.parseInt(st.nextToken());
	    	if(map.containsKey(X)) {
	    		map.put(X, map.get(X)+1);
	    	} else {
	    		map.put(X, 1);
	    	}
	    }

	    //System.out.println(map);

	    int leftKey = map.firstKey(), rightKey = map.lastKey();

	    long numChanged = 0;
	    long left = 0, right = 0;
	    while(map.size() > necessary) {
	    	numChanged += Math.min(map.get(leftKey), map.get(rightKey));
	    	if(map.get(leftKey)+left > map.get(rightKey)+right) {
	    		right += map.get(rightKey);
	    		int T = map.lowerKey(rightKey);
	    		map.remove(rightKey);
	    		rightKey = T;
	    	} else {
	    		left += map.get(leftKey);
	    		int T = map.higherKey(leftKey);
	    		map.remove(leftKey);
	    		leftKey = T;
	    	}
	    }

	    out.println(numChanged);
	    out.close();
	    f.close();

	}

}
/*
import java.util.*;
import java.io.*;

public class mp3 {

	public static void main (String [] args) throws Exception {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	    StringTokenizer st = new StringTokenizer(f.readLine());
	    long N = Integer.parseInt(st.nextToken());
	    long I = Integer.parseInt(st.nextToken()) * 8;

	    st = new StringTokenizer(f.readLine());
	    TreeMap<Integer, Integer> map = new TreeMap<>();
	    for(long i = 0; i < N; i++) {
	    	int X = Integer.parseInt(st.nextToken());
	    	if(map.containsKey(X)) {
	    		map.put(X, map.get(X)+1);
	    	} else {
	    		map.put(X, 1);
	    	}
	    }

	    //System.out.println(map);

	    int leftKey = map.firstKey(), rightKey = map.lastKey();

	    long numChanged = 0;
	    long size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2));
	    while(size > I) {
	    	numChanged += Math.min(map.get(leftKey), map.get(rightKey));
	    	if(map.get(leftKey) > map.get(rightKey)) {
	    		int T = map.lowerKey(rightKey);
	    		map.remove(rightKey);
	    		rightKey = T;
	    	} else {
	    		int T = map.higherKey(leftKey);
	    		map.remove(leftKey);
	    		leftKey = T;
	    	}

	    	size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2));
	    }

	    out.println(numChanged);
	    out.close();
	    f.close();

	}

}
*/


import java.util.*;
import java.io.*;
import java.util.concurrent.TimeUnit;

public class mp3 {

	public static void main (String [] args) throws Exception {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	    StringTokenizer st = new StringTokenizer(f.readLine());
	    int N = Integer.parseInt(st.nextToken());
	    int I = Integer.parseInt(st.nextToken()) * 8;

	    st = new StringTokenizer(f.readLine());
	    TreeMap<Integer, Integer> map = new TreeMap<>();
	    for(int i = 0; i < N; i++) {
	    	int X = Integer.parseInt(st.nextToken());
	    	if(map.containsKey(X)) {
	    		map.put(X, map.get(X)+1);
	    	} else {
	    		map.put(X, 1);
	    	}
	    }

	    //System.out.println(map);

	    int leftKey = map.firstKey(), rightKey = map.lastKey();

	    int numChanged = 0;
	    int size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2)-0.0005);
	    while(size > I) {
	    	numChanged += Math.min(map.get(leftKey), map.get(rightKey));
	    	if(map.get(leftKey) > map.get(rightKey)) {
	    		int T = map.lowerKey(rightKey);
	    		map.remove(rightKey);
	    		rightKey = T;
	    	} else {
	    		int T = map.higherKey(leftKey);
	    		map.remove(leftKey);
	    		leftKey = T;
	    	}

	    	size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2));
	    }

	    out.println(numChanged);
	    out.close();
	    f.close();
	}

}


import java.util.*;
import java.io.*;
import java.util.concurrent.TimeUnit;

public class mp3 {

	public static void main (String [] args) throws Exception {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	    StringTokenizer st = new StringTokenizer(f.readLine());
	    int N = Integer.parseInt(st.nextToken());
	    int I = Integer.parseInt(st.nextToken()) * 8;

	    st = new StringTokenizer(f.readLine());
	    TreeMap<Integer, Integer> map = new TreeMap<>();
	    for(int i = 0; i < N; i++) {
	    	int X = Integer.parseInt(st.nextToken());
	    	if(map.containsKey(X)) {
	    		map.put(X, map.get(X)+1);
	    	} else {
	    		map.put(X, 1);
	    	}
	    }

	    //System.out.println(map);

	    int leftKey = map.firstKey(), rightKey = map.lastKey();

	    int numChanged = 0;
	    int size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2));
	    while(size > I) {
	    	numChanged += Math.min(map.get(leftKey), map.get(rightKey));
	    	if(map.get(leftKey) > map.get(rightKey)) {
	    		int T = map.lowerKey(rightKey);
	    		map.remove(rightKey);
	    		rightKey = T;
	    	} else {
	    		int T = map.higherKey(leftKey);
	    		map.remove(leftKey);
	    		leftKey = T;
	    	}

	    	size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2));
	    }

	    out.println(numChanged);
	    out.close();
	    f.close();
	}

}


import java.util.*;
import java.io.*;
import java.util.concurrent.TimeUnit;

public class mp3 {

	public static void main (String [] args) throws Exception {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	    StringTokenizer st = new StringTokenizer(f.readLine());
	    int N = Integer.parseInt(st.nextToken());
	    int I = Integer.parseInt(st.nextToken()) * 8;

	    st = new StringTokenizer(f.readLine());
	    TreeMap<Integer, Integer> map = new TreeMap<>();
	    for(int i = 0; i < N; i++) {
	    	int X = Integer.parseInt(st.nextToken());
	    	if(map.containsKey(X)) {
	    		map.put(X, map.get(X)+1);
	    	} else {
	    		map.put(X, 1);
	    	}
	    }

	    //System.out.println(map);

	    int leftKey = map.firstKey(), rightKey = map.lastKey();

	    int numChanged = 0;
	    int size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2)-0.0005);
	    while(size > I) {
	    	numChanged += Math.min(map.get(leftKey), map.get(rightKey));
	    	if(map.get(leftKey) > map.get(rightKey)) {
	    		int T = map.lowerKey(rightKey);
	    		map.remove(rightKey);
	    		rightKey = T;
	    	} else {
	    		int T = map.higherKey(leftKey);
	    		map.remove(leftKey);
	    		leftKey = T;
	    	}

	    	size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2)-0.0005);
	    }

	    out.println(numChanged);
	    out.close();
	    f.close();
	}

}


import java.util.*;
import java.io.*;

public class mp3 {
	static int[] occurrences;

	public static void main (String [] args) throws IOException {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(System.out, true);

	    StringTokenizer st =  new StringTokenizer(f.readLine());
	    int n = Integer.parseInt(st.nextToken());
	    int I = Integer.parseInt(st.nextToken()) * 8;

	    occurrences = new int[n + 1];
	    int distinctValues = 0;
	    st = new StringTokenizer(f.readLine());
	    for(int i = 0; i < n; i++) {
	    	int temp = Integer.parseInt(st.nextToken());
	    	if(occurrences[temp] == 0)
	    		distinctValues++;
	    	occurrences[temp]++;
	    }

	    List<Integer> occur = new ArrayList<Integer>();

	    for(int i = 0; i < n; i++) {
	    	if(occurrences[i] != 0) {
	    		occur.add(occurrences[i]);
	    	}
	    }

	    Collections.sort(occur);

	    double nk = n * Math.ceil(Math.log(distinctValues)/Math.log(2));
	    int changedValues = 0;
	    while(nk > I) {
	    	changedValues += occur.get(0);
	    	distinctValues--;
		    nk = n * Math.ceil(Math.log(distinctValues)/Math.log(2));
		    occur.remove(0);
	    }

	    out.println(changedValues);
	    out.close();

	}

}


import java.util.*;
import java.io.*;

public class mp3 {
	static int[] occurrences;

	public static void main (String [] args) throws IOException {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(System.out, true);

	    StringTokenizer st =  new StringTokenizer(f.readLine());
	    int n = Integer.parseInt(st.nextToken());
	    int I = Integer.parseInt(st.nextToken()) * 8;

	    occurrences = new int[400000];
	    int distinctValues = 0;
	    st = new StringTokenizer(f.readLine());
	    for(int i = 0; i < n; i++) {
	    	int temp = Integer.parseInt(st.nextToken());
	    	if(occurrences[temp] == 0)
	    		distinctValues++;
	    	occurrences[temp]++;
	    }

	    //System.out.println(Arrays.toString(occurrences));

	    int lowerLimit = 0;
	    int upperLimit = occurrences.length - 1;
	    double nk = n * Math.ceil(Math.log(distinctValues)/Math.log(2));
	    int changedValues = 0;
	    while(nk > I) {
	    	while(occurrences[lowerLimit] == 0)
	    		lowerLimit++;
	    	while(occurrences[upperLimit] == 0)
	    		upperLimit--;
	    	changedValues += Math.min(occurrences[lowerLimit], occurrences[upperLimit]);
	    	distinctValues--;
		    nk = n * Math.ceil(Math.log(distinctValues)/Math.log(2));
		    if(occurrences[lowerLimit] > occurrences[upperLimit])
		    	occurrences[upperLimit] = 0;
		    else
		    	occurrences[lowerLimit] = 0;
	    }

	    //System.out.println(Arrays.toString(occurrences));

	    out.println(changedValues);
	    out.close();

	}

}


import java.util.*;
import java.io.*;

public class mp3 {
	static int[] occurrences;

	public static void main (String [] args) throws IOException {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(System.out, true);

	    StringTokenizer st =  new StringTokenizer(f.readLine());
	    int n = Integer.parseInt(st.nextToken());
	    int I = Integer.parseInt(st.nextToken()) * 8;

	    occurrences = new int[9999999];
	    int distinctValues = 0;
	    st = new StringTokenizer(f.readLine());
	    for(int i = 0; i < n; i++) {
	    	int temp = Integer.parseInt(st.nextToken());
	    	if(occurrences[temp] == 0)
	    		distinctValues++;
	    	occurrences[temp]++;
	    }

	    //System.out.println(Arrays.toString(occurrences));

	    int lowerLimit = 0;
	    int upperLimit = occurrences.length - 1;
	    double nk = n * Math.ceil(Math.log(distinctValues)/Math.log(2));
	    int changedValues = 0;
	    while(nk > I) {
	    	while(occurrences[lowerLimit] == 0)
	    		lowerLimit++;
	    	while(occurrences[upperLimit] == 0)
	    		upperLimit--;
	    	changedValues += Math.min(occurrences[lowerLimit], occurrences[upperLimit]);
	    	distinctValues--;
		    nk = n * Math.ceil(Math.log(distinctValues)/Math.log(2));
		    if(occurrences[lowerLimit] > occurrences[upperLimit])
		    	occurrences[upperLimit] = 0;
		    else
		    	occurrences[lowerLimit] = 0;
	    }

	    //System.out.println(Arrays.toString(occurrences));

	    out.println(changedValues);
	    out.close();

	}

}


import java.util.*;
import java.io.*;

public class mp3 {
	static Map<Integer, Integer> map = new HashMap<Integer, Integer>();
	static List<Integer> lis = new ArrayList<Integer>();
	public static void main (String [] args) throws IOException {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(System.out, true);

	    StringTokenizer st =  new StringTokenizer(f.readLine());
	    int n = Integer.parseInt(st.nextToken());
	    int I = Integer.parseInt(st.nextToken()) * 8;

	    int distinctValues = 0;
	    st = new StringTokenizer(f.readLine());
	    for(int i = 0; i < n; i++) {
	    	int temp = Integer.parseInt(st.nextToken());
	    	if(!map.containsKey(temp)) {
	    		distinctValues++;
	    		map.put(temp,  1);
	    	} else
	    		map.put(temp, map.get(temp) + 1);
	    }

	    for(int each: map.keySet()) {
	    	lis.add(map.get(each));
	    }
	    Collections.sort(lis);

	    double nk = n * Math.ceil(Math.log(distinctValues)/Math.log(2));
	    int changedValues = 0;
	    int lowerLimit = 0;
	    int upperLimit = lis.size() - 1;
	    while(nk > I) {
	    	changedValues += Math.min(lis.get(lowerLimit), lis.get(upperLimit));
	    	distinctValues--;
		    nk = n * Math.ceil(Math.log(distinctValues)/Math.log(2));
		    if(lis.get(lowerLimit) > lis.get(upperLimit))
		    	upperLimit--;
		    else
		    	lowerLimit++;
	    }

	    //System.out.println(Arrays.toString(occurrences));

	    out.println(changedValues);
	    out.close();

	}

}


import java.util.*;
import java.io.*;

public class mp3 {

	public static void main (String [] args) throws Exception {
		for(int i = 400000; i >= 1; i--) {
	    	System.out.println(400000 * (int)Math.ceil(Math.log(i)/Math.log(2)));
	    }
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	    StringTokenizer st = new StringTokenizer(f.readLine());
	    int N = Integer.parseInt(st.nextToken());
	    int I = Integer.parseInt(st.nextToken()) * 8;

	    st = new StringTokenizer(f.readLine());
	    TreeMap<Integer, Integer> map = new TreeMap<>();
	    for(int i = 0; i < N; i++) {
	    	int X = Integer.parseInt(st.nextToken());
	    	if(map.containsKey(X)) {
	    		map.put(X, map.get(X)+1);
	    	} else {
	    		map.put(X, 1);
	    	}
	    }

	    //System.out.println(map);

	    int leftKey = map.firstKey(), rightKey = map.lastKey();

	    int numChanged = 0;
	    int size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2)-0.00005);
	    while(size > I) {
	    	numChanged += Math.min(map.get(leftKey), map.get(rightKey));
	    	if(map.get(leftKey) > map.get(rightKey)) {
	    		int T = map.lowerKey(rightKey);
	    		map.remove(rightKey);
	    		rightKey = T;
	    	} else {
	    		int T = map.higherKey(leftKey);
	    		map.remove(leftKey);
	    		leftKey = T;
	    	}

	    	size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2)-0.00005);
	    }

	    out.println(numChanged);
	    out.close();
	    f.close();

	}

}


import java.util.*;
import java.io.*;

public class mp3 {

	public static void main (String [] args) throws Exception {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	    StringTokenizer st = new StringTokenizer(f.readLine());
	    long N = Integer.parseInt(st.nextToken());
	    long I = Integer.parseInt(st.nextToken()) * 8;

	    st = new StringTokenizer(f.readLine());
	    TreeMap<Integer, Integer> map = new TreeMap<>();
	    for(long i = 0; i < N; i++) {
	    	int X = Integer.parseInt(st.nextToken());
	    	if(map.containsKey(X)) {
	    		map.put(X, map.get(X)+1);
	    	} else {
	    		map.put(X, 1);
	    	}
	    }

	    //System.out.println(map);

	    int leftKey = map.firstKey(), rightKey = map.lastKey();

	    long numChanged = 0;
	    long necessary = 1l<<(I/N);
	    while(map.size() > necessary) {
	    	numChanged += Math.min(map.get(leftKey), map.get(rightKey));
	    	if(map.get(leftKey) > map.get(rightKey)) {
	    		int T = map.lowerKey(rightKey);
	    		map.remove(rightKey);
	    		rightKey = T;
	    	} else {
	    		int T = map.higherKey(leftKey);
	    		map.remove(leftKey);
	    		leftKey = T;
	    	}
	    }

	    out.println(numChanged);
	    out.close();
	    f.close();

	}

}
/*
import java.util.*;
import java.io.*;

public class mp3 {

	public static void main (String [] args) throws Exception {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	    StringTokenizer st = new StringTokenizer(f.readLine());
	    long N = Integer.parseInt(st.nextToken());
	    long I = Integer.parseInt(st.nextToken()) * 8;

	    st = new StringTokenizer(f.readLine());
	    TreeMap<Integer, Integer> map = new TreeMap<>();
	    for(long i = 0; i < N; i++) {
	    	int X = Integer.parseInt(st.nextToken());
	    	if(map.containsKey(X)) {
	    		map.put(X, map.get(X)+1);
	    	} else {
	    		map.put(X, 1);
	    	}
	    }

	    //System.out.println(map);

	    int leftKey = map.firstKey(), rightKey = map.lastKey();

	    long numChanged = 0;
	    long size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2));
	    while(size > I) {
	    	numChanged += Math.min(map.get(leftKey), map.get(rightKey));
	    	if(map.get(leftKey) > map.get(rightKey)) {
	    		int T = map.lowerKey(rightKey);
	    		map.remove(rightKey);
	    		rightKey = T;
	    	} else {
	    		int T = map.higherKey(leftKey);
	    		map.remove(leftKey);
	    		leftKey = T;
	    	}

	    	size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2));
	    }

	    out.println(numChanged);
	    out.close();
	    f.close();

	}

}
*/


import java.util.*;
import java.io.*;

public class mp3 {

	public static void main (String [] args) throws Exception {
	    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	    StringTokenizer st = new StringTokenizer(f.readLine());
	    long N = Integer.parseInt(st.nextToken());
	    long I = Integer.parseInt(st.nextToken()) * 8;

	    st = new StringTokenizer(f.readLine());
	    TreeMap<Integer, Integer> map = new TreeMap<>();
	    for(long i = 0; i < N; i++) {
	    	int X = Integer.parseInt(st.nextToken());
	    	if(map.containsKey(X)) {
	    		map.put(X, map.get(X)+1);
	    	} else {
	    		map.put(X, 1);
	    	}
	    }

	    //System.out.println(map);

	    int leftKey = map.firstKey(), rightKey = map.lastKey();

	    long numChanged = 0;
	    long size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2));
	    while(size > I) {
	    	numChanged += Math.min(map.get(leftKey), map.get(rightKey));
	    	if(map.get(leftKey) > map.get(rightKey)) {
	    		int T = map.lowerKey(rightKey);
	    		map.remove(rightKey);
	    		rightKey = T;
	    	} else {
	    		int T = map.higherKey(leftKey);
	    		map.remove(leftKey);
	    		leftKey = T;
	    	}

	    	size = N * (int)Math.ceil(Math.log(map.size())/Math.log(2));
	    }

	    out.println(numChanged);
	    out.close();
	    f.close();

	}

}