#include <bits/stdc++.h>

using namespace std;

#define rep(i,n)      for(long long(i)=0;(i)<(n);(i)++)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

int main(){

    string s;
    cin >> s;

    rep(i,s.length()){
        if(i & 0x01){
            if(s[i] < 'A' || 'Z' < s[i]){
                cout << "No" << endl;
                return 0;
            }
        } else {
            if(s[i] < 'a' || 'z' < s[i]){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define endl "\n"
#define Endl "\n"
#define emdl "\n"
#define mod 1000000007
#define pb push_back
// #define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
// bool sortBy(const pair<int,pair<int,int>> &a,const pair<int,pair<int,int>> &b){
// 	if(a.S.F==b.S.F)
// 		return a.F<b.F;
// 	return a.S.F<b.S.F;
// }

// #define MAXN 5000003
// int pf[MAXN];
// vector<int> primes;
// void sieve(){
// 	long long int i,j;
//     pf[1] = 1;
//     for (i=2; i<MAXN; i++)
//     pf[i] = i;
//     for (i=2; i*i<MAXN; i++){
//         if (pf[i] == i){
//             for (j=i*i; j<MAXN; j+=i)
//                 if (pf[j]==j)
//                     pf[j] = i;
//         }
//     }
// 	for(int i=2;i<MAXN;i++){
// 		if(pf[i]==i){
// 			primes.push_back(i);
// 		}
// 	}
// }
// vector<int> factors(int x){
//     vector<int> ret;
//     while (x != 1){
// 		int fact=pf[x];
//         ret.push_back(pf[x]);
// 		while(fac!=1&&x%fact==0)
//         x/=fact;
//     }
//     return ret;
// }
// set<long long int>poww;
// void init(){
// 	long long int temp=1;
// 	for(int i=1;i<43;i++){
// 		poww.insert(temp);
// 		temp*=2;
// 	}
// }

// int summ(long long int n){
//     int cnt=0;
//     while(n){
//         cnt+=n%10;
//         n/=10;
//     }
//     return cnt;
// }

void init(){

}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	int qwe=1;
 	//cin>>qwe;
	init();
	//sieve();
	while(qwe--){

		int h,w;
		cin>>h>>w;

		int a[h][w];

		string s[h];

		for(int i=0;i<h;i++){
			cin>>s[i];
			for(int j=0;j<w;j++){
				if(s[i][j]=='#'){
					a[i][j]=1;
				}else{
					a[i][j]=0;
				}
				// cout<<a[i][j]<<" ";
			}
			// cout<<endl;
		}

		int count =0;

		for(int i=1;i<h-1;i++){
			for(int j=1;j<w-1;j++){
				if(a[i][j]==0){
					continue;
				}

				// cout<<"1 ";

				if(a[i][j-1]==0&&a[i-1][j]==0&&a[i-1][j-1]==0){
					count++;
				}
				 if(a[i][j+1]==0&&a[i-1][j]==0&&a[i-1][j+1]==0){
					count++;
				}
				if(a[i][j-1]==0&&a[i+1][j]==0&&a[i+1][j-1]==0){
					count++;
				}
				if(a[i][j+1]==0&&a[i+1][j]==0&&a[i+1][j+1]==0){
					count++;
				}
				if(a[i][j-1]==a[i-1][j]&&a[i][j-1]==1&&a[i-1][j-1]==0){
					count++;
				}
				if(a[i][j-1]==a[i+1][j]&&a[i][j-1]==1&&a[i+1][j-1]==0){
					count++;
				}
				if(a[i][j+1]==a[i-1][j]&&a[i][j+1]==1&&a[i-1][j+1]==0){
					count++;
				}
				if(a[i][j+1]==a[i+1][j]&&a[i][j+1]==1&&a[i+1][j+1]==0){
					count++;
				}
			}
			// cout<<endl;
		}

		cout<<count<<endl;

	}

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define rep(i,n)for(int i=0;i<(int)(n);++i)
#define fixed(n)fixed<<setprecision(n)
#define ll long long
#define ALL(a)a.begin(),a.end()
#define LLA(a)a.rbegin(),a.rend()

template<class T>void chmin(T& a,T b){
    if(a>b){
        a=b;
    }
}
template<class T>void chmax(T& a,T b){
    if(a<b){
        a=b;
    }
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}

const long long INF=1LL<<60;
const long long MOD=1000000007;

int main(){
    int H,W;cin>>H>>W;
    vector<vector<int>>ms(H,vector<int>(W));
    rep(i,H)rep(j,W){
        char c;cin>>c;
        if(c=='#')ms[i][j]=1;
        else ms[i][j]=0;
    }
    int res=0;
    rep(i,H-1)rep(j,W-1){
        int a=ms[i][j]+ms[i+1][j]+ms[i][j+1]+ms[i+1][j+1];
        if(a==1||a==3)res++;
    }
    cout<<res;
}


#include<bits/stdc++.h>
using namespace std;
namespace Sakurajima_Mai{
    #define ms(a) memset(a,0,sizeof(a))
    #define repi(i,a,b) for(int i=a,bbb=b;i<=bbb;++i)//attention reg int or reg ll ?
    #define repd(i,a,b) for(int i=a,bbb=b;i>=bbb;--i)
    #define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
    #define ce(i,r) i==r?'\n':' '
    #define pb push_back
    #define all(x) x.begin(),x.end()
    #define gmn(a,b) a=min(a,b)
    #define gmx(a,b) a=max(a,b)
    #define fi first
    #define se second
    typedef long long ll;
    typedef unsigned long long ull;
    typedef double db;
    const int infi=2e9;//infi较大，注意涉及inf相加时爆int
    const ll infl=4e18;
    inline ll ceil_div(ll a,ll b){ return (a+b-1)/b; }
    inline ll pos_mod(ll a,ll b){ return (a%b+b)%b; }
    //std::mt19937 rnd(time(0));//std::mt19937_64 rnd(time(0));
}
using namespace Sakurajima_Mai;
namespace Fast_Read{
    inline int qi(){
        int f=0,fu=1; char c=getchar();
        while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
        while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
        return f*fu;
    }
    inline ll ql(){
        ll f=0;int fu=1; char c=getchar();
        while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
        while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
        return f*fu;
    }
    inline db qd(){
        char c=getchar();int flag=1;double ans=0;
        while((!(c>='0'&&c<='9'))&&c!='-') c=getchar();
        if(c=='-') flag=-1,c=getchar();
        while(c>='0'&&c<='9') ans=ans*10+(c^48),c=getchar();
        if(c=='.'){c=getchar();for(int Bit=10;c>='0'&&c<='9';Bit=(Bit<<3)+(Bit<<1)) ans+=(double)(c^48)*1.0/Bit,c=getchar();}
        return ans*flag;
    }
}
namespace Read{
    #define si(a) scanf("%d",&a)
    #define sl(a) scanf("%lld",&a)
    #define sd(a) scanf("%lf",&a)
    #define ss(a) scanf("%s",a)
    #define rai(x,a,b) repi(i,a,b) x[i]=qi()
    #define ral(x,a,b) repi(i,a,b) x[i]=ql()
}
namespace Out{
    #define pi(x) printf("%d",x)
    #define pl(x) printf("%lld",x)
    #define ps(x) printf("%s",x)
    #define pc(x) printf("%c",x)
    #define pe() puts("")
}
namespace DeBug{
    #define MARK false
    #define DB if(MARK)
    #define pr(x) cout<<#x<<": "<<x<<endl
    #define pra(x,a,b) cout<<#x<<": "<<endl; \
            repi(i,a,b) cout<<x[i]<<" ";     \
            puts("");
    #define FR(a) freopen(a,"r",stdin)
    #define FO(a) freopen(a,"w",stdout)
}
using namespace Fast_Read;
using namespace Read;
using namespace Out;
using namespace DeBug;
const int MAX_N=3e5+5;
int cnt[MAX_N];
int main()
{
    int n=qi();
    repi(i,1,n) cnt[qi()+200]++;
    ll ans=0;
    repi(i,0,400)repi(j,0,400) ans+=1ll*cnt[i]*cnt[j]*(i-j)*(i-j);
    pl(ans/2),pe();
    return 0;
}

#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <set>
#include <vector>

#define ALL(container) container.begin(), container.end()
#define REP(counter, end) for (int counter = 0; counter < end; ++counter)

using namespace std;
using ll = long long;

const int MAX_A = 200;

int main() {
    int n{};
    cin >> n;

    auto a = vector<int>(n);
    auto d = vector<int>(MAX_A * 2 + 1);
    REP(i, n) {
        cin >> a[i];
        d[MAX_A + a[i]]++;
    }

    ll ans = 0;

    REP(ai, d.size()) {
        REP(aj, ai) {
            ll x = ai - aj;
            ans += x * x * d[ai] * d[aj];
        }
    }

    cout << ans << endl;

    return 0;
}


#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
#define NDEBUG
#endif
#include<bits/stdc++.h>
#define int long long
#define LL long long
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef pair<int,int>PII;typedef vector<int>VI;typedef vector<PII>VII;
template<typename T>void rd(T&x){int f=0,c;while(!isdigit(c=getchar()))f^=!(c^45);x=(c&15);while(isdigit(c=getchar()))x=x*10+(c&15);if(f)x=-x;}
template<typename T>void pt(T x,int c=-1){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);if(c!=-1)putchar(c);}
const int N=100005;
int n,len,A[N],B[N],C[N];
signed main(){
	rd(n);
	int sum=0;
	rep(i,1,n)rd(A[i]),sum+=A[i];
	rep(i,1,n){
		int x;rd(x),x-=A[i];
		if(i&1){
			B[++len]=x;
		}else{
			C[len]=x;
		}
	}
	sort(B+1,B+1+len,[&](int x,int y){return x>y;});
	sort(C+1,C+1+len,[&](int x,int y){return x>y;});
	int ans=sum;
	rep(i,1,len){
		sum+=B[i]+C[i];
		ans=max(ans,sum);
	}
	pt(ans,'\n');
	return 0;
}

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

int a[100010], b[100010];
long long dp[100010];
int s[100010];

int main () {
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	for (int j = 1; j <= n; j++) {
		scanf("%d", &b[j]);
	}
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] > b[i]) s[i] = 0;
		else s[i] = 1;
		ans += max(a[i], b[i]);
	}
	int x = 0, y = 0;
	for (int i = 1; i <= n; i += 2) {
		if (s[i] == 0 && s[i + 1] == 1) x++;
		if (s[i] == 1 && s[i + 1] == 0) y++;
	}
	if (x == y) {
		printf("%lld\n", ans);
		return 0;
	}
	vector <int> all;
	if (x > y) {
		for (int i = 1; i <= n; i += 2) {
			if (s[i] != 1) all.push_back(b[i] - a[i]);
			if (s[i + 1] != 0) all.push_back(a[i + 1] - b[i + 1]);
		}
	} else {
		for (int i = 1; i <= n; i += 2) {
			if (s[i] != 0) all.push_back(a[i] - b[i]);
			if (s[i + 1] != 1) all.push_back(b[i + 1] - a[i + 1]);
		}
		swap(x, y);
	}
	sort(all.begin(), all.end()), reverse(all.begin(), all.end());
	int T = x - y;
	for (int i = 0; i < T; i++) {
		ans += all[i];
	}
	printf("%lld\n", ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  int x, y;
  cin >> x >> y;

  if (x == y) cout << x << endl;
  else cout << 3 - x - y << endl;

  return 0;
}

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

typedef long long ll;
typedef vector<ll>vl1;
typedef vector<vl1> vl2;

struct struka
{ll val; ll ind;};
typedef vector<struka> vs;

bool compa(struka& a, struka& b)
{ if(a.val==b.val) return a.ind<b.ind;
  return a.val<b.val;
}

ll lova(vl1&  veka, ll dole, ll gore, ll val)
{ ll sred;
  while(dole<=gore)
  {sred=(gore+dole)/2;
   if(veka[sred]>=val) gore=sred-1;// real condition !
   else dole=sred+1;
  }
 return dole;
}

ll gcd(ll a,ll b)
{ll t;
  while (b)
  { t= b;
    b = a % b;
    a = t;
  }
return a;
}

void radi()
{ ll i, j, k, kn, m, n, p, t, l, r, x, y, z, a, b, c, d;
  ll val, pos, tmp, suma, maxa, mina, naso, num;
  string str1;
  char ch1;
  cin>>a>>b;
  c=(a+b)%3;
  val=(3-c)%3;
  cout<<val<<'\n';

}

int main()
{ /*
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(nullptr);
  cout<<fixed<<setprecision(15);
  */

  ll t, p;
  t=1;
  for(p=1;p<=t;p++) radi();
  return 0;
}
/*

*/


#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define rep2(i, a, b) for(int i=a; i<b; i++)
#define Pii pair<int, int>
#define Pll pair<ll, ll>
using namespace std;
using ll = long long;

int main(){
    char s, t;
    cin >> s >> t;
    if(s=='Y'){
        if(t=='a') cout<<'A'<<endl;
        if(t=='b') cout<<'B'<<endl;
        if(t=='c') cout<<'C'<<endl;
    }
    if(s=='N'){
        if(t=='a') cout<<'a'<<endl;
        if(t=='b') cout<<'b'<<endl;
        if(t=='c') cout<<'c'<<endl;
    }
    return 0;
}

#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP2(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = (l), i##_len = (int)(r); i < i##_len; ++i)
#define GET_MACRO_REP(_1, _2, _3, NAME, ...) NAME
#define REP(...) GET_MACRO_REP(__VA_ARGS__, REP3, REP2) (__VA_ARGS__)
#define RREP2(i, n) for (int i = (n - 1); i >= 0; --i)
#define RREP3(i, l, r) for (int i = (r - 1), i##_len = (l); i >= i##_len; --i)
#define GET_MACRO_RREP(_1, _2, _3, NAME, ...) NAME
#define RREP(...) GET_MACRO_REP(__VA_ARGS__, RREP3, RREP2) (__VA_ARGS__)
#define IN(type, n) type n; cin >> n
#define INALL(type, v) REP(i, v.size()) { IN(type, _tmp); v.at(i) = _tmp; }
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl
#else
#define DEBUG(x)
#endif

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }
#pragma endregion

int main() {
  IN(char, S);
  IN(char, T);
  if (S == 'Y') {
    cout << (char)(T + ('A' - 'a')) << endl;
  } else {
    cout << T << endl;
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define FOR(i, j, k, in) for (int i = j; i < k; i += in)
#define RFOR(i, j, k, in) for (int i = j; i >= k; i -= in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, m, x, y;
    cin >> n >> m >> x >> y;
    x--, y--;
    vector<vector<tuple<ll, ll, ll>>> graph(n);
    vector<ll> distance(n, -1);
    REP(i, m) {
        ll ai, bi, ti, ki;
        cin >> ai >> bi >> ti >> ki;
        ai--, bi--;
        graph[ai].emplace_back(bi, ti, ki);
        graph[bi].emplace_back(ai, ti, ki);
    }

    vector<pair<ll, ll>> heap = {{0, x}};
    auto comp = [](const pair<ll, ll> &lhs, const pair<ll, ll> &rhs) {
        return lhs.first > rhs.first;
    };

    while (!heap.empty()) {
        pop_heap(begin(heap), end(heap), comp);
        auto p = heap.back();
        heap.pop_back();
        ll dist = p.first, pos = p.second;
        if (distance[pos] != -1) continue;
        distance[pos] = dist;
        if (pos == y) break;
        for (const auto tup : graph[pos]) {
            ll to = get<0>(tup), ti = get<1>(tup), ki = get<2>(tup);
            if (distance[to] != -1) continue;
            ll start;
            if (dist % ki == 0)
                start = (dist / ki) * ki;
            else
                start = (dist / ki + 1) * ki;
            heap.emplace_back(start + ti, to);
            push_heap(begin(heap), end(heap), comp);
        }
    }
    cout << distance[y] << endl;
    return 0;
}

#pragma GCC optimize ("O2")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
//#include<atcoder/all>
//using namespace atcoder;

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char cn[1200010];
char* ci = cn, * di = cn;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	fread(cn, 1, 1200010, stdin);
	int T = getint();

	rep(t, T) {
		int N = getint();

		rep(i, N)* di++ = '0';
		rep(i, N)* di++ = '1';
		*di++ = '0';
		*di++ = '\n';
		ci += 6 * N + 3;
	}
	fwrite(cn, 1, di - cn, stdout);

	Would you please return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define ar array

const int N=2e5;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	ar<int, 2> res[n];
	if (n==1) {
		if (m==0) cout << 1 << " " << 2;
		else cout << -1;
		return 0;
	}
	if (m==n||m==n-1||m<0) {
		cout << -1;
		return 0;
	}
	res[0][0]=1;
	res[0][1]=2*m+4;
	for (int i=1; i<m+2; i++) {
		res[i][0]=2*i;
		res[i][1]=2*i+1;
	}
	for (int i=m+2; i<n; i++) {
		res[i][0]=2*i+1;
		res[i][1]=2*i+2;
	}

	for (int i=0; i<n; i++) {
		cout << res[i][0] << " " << res[i][1] << "\n";
	}
	return 0;
}

//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prinp(p) cout<<p.first<<" "<<p.second<<endl
#define prinv(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1e9+7,MAX = 2e5+5;
const ll INF = 1e18+5;

int main()
{
	int n,m;
	cin>>n>>m;
	if(n==1)
	{
		if(m==-1||m==-1) cout<<-1<<endl;
		else
		{
			cout<<1<<" "<<2<<endl;
		}
		return 0;
	}
	if(m<0||m>=n-1) cout<<-1<<endl;
	else
	{
		for(int i=0;i<m+1;i++)
		{
			cout<<2+2*i<<" "<<2+2*i+1<<endl;
		}
		cout<<1<<" "<<4+2*m<<endl;

		for(int i=m+2;i<n;i++)
		{
			cout<<4+2*m+2*(i-m-2)+1<<" "<<4+2*m+2*(i-m-2)+2<<endl;
		}
	}
}


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

#define nl "\n"
#define nf endl
#define ll long long
#define pb push_back
#define _ << ' ' <<

#define INF (ll)1e18
#define mod 998244353
#define maxn 110

ll i, i1, j, k, k1, t, n, m, res, flag[10], a, b;
ll x, y, z, tt, sm;

ll bnm2(ll x) {
    if (x < 0) return 0;
    return (x * (x - 1)) / 2;
}

ll bnm1(ll x) {
    if (x < 0) return 0;
    return x;
}

ll calc2(ll x) {
    return bnm2(x + 2) - 3 * bnm2(x - n + 1) +
    3 * bnm2(x - 2 * n) - bnm2(x - 3 * n - 1);
}

ll calc1(ll x) {
    return bnm1(x + 1) - 2 * bnm1(x - n) +
    bnm1(x - 2 * n - 1);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    #if !ONLINE_JUDGE && !EVAL
        ifstream cin("input.txt");
        ofstream cout("output.txt");
    #endif

    cin >> n >> k; n--;
    for (i = 0; i <= 3 * n; i++) {
        // cout << "calc2 " << i _ calc2(i) << nl;
        if (tt + calc2(i) >= k) {
            sm = i; break;
        } else {
            tt += calc2(i);
        }
    }

    // cout << "sm = " << sm << nl;

    for (i = 0; i <= n; i++) {
        if (tt + calc1(sm - i) >= k) {
            x = i; break;
        } else {
            tt += calc1(sm - i);
        }
    }

    z = min(n, sm - x) - (k - tt) + 1;
    y = sm - x - z;
    x++; y++; z++;

    cout << x _ y _ z << nl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
  int N, K;
  cin >> N >> K;
  vector<vector<int>> a(N, vector<int>(N));
  rep(i, N) rep(j, N) cin >> a[i][j];

  auto check = [=](int x) {
    vector<vector<int>> sum(N + 1, vector<int>(N + 1, 0));
    rep(i, N) rep(j, N) {
      sum[i + 1][j + 1] =
          sum[i][j + 1] + sum[i + 1][j] - sum[i][j] + (a[i][j] <= x);
    }
    rep(i, N - K + 1) rep(j, N - K + 1) {
      int countNoMoreThanX =
          sum[i + K][j + K] - sum[i][j + K] - sum[i + K][j] + sum[i][j];
      if (countNoMoreThanX >= (K * K + 1) / 2) return true;
    }
    return false;
  };

  int ng = -1, ok = 1e9;
  while (ok - ng > 1) {
    int mid = (ng + ok) / 2;
    if (check(mid))
      ok = mid;
    else
      ng = mid;
  }
  cout << ok << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

const ll MAX = 100008;
ll n, a[MAX], b[MAX];

int main(){
    cin.tie(0); ios::sync_with_stdio(false);

    ll n; cin >> n;
    ll a[n], b[n];
    zep(i, 0, n)cin >> a[i];
    zep(i, 0, n)cin >> b[i];

    ll ans = 0;
    zep(i, 0, n)ans += a[i];

    ll c[2][n / 2];

    zep(i, 0, n)c[i % 2][i / 2] = b[i] - a[i];
    sort(c[0], c[0] + n / 2);
    sort(c[1], c[1] + n / 2);

    zep(i, 0, n / 2)if(c[0][i] + c[1][i] > 0)ans += c[0][i] + c[1][i];

    print(ans);

    return 0;
}

#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector

typedef long long ll;

using namespace std;

// イテレーション
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define repk(i, k, n) for (ll i = k; i < ll(n); i++)

// x:コンテナ
#define ALL(vec) vec.begin(), vec.end()
#define SIZE(x) ll(x.size())

#define debug(x) cout << "debug: " << x << endl

// 定数
#define MOD 1000000007
const int INF = 1073741823;
const ll INFL = 1LL << 60;

template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

void solve() {
  //
  ll n;
  int k;

  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    if (n % 200 == 0) {
      n = n / 200;
    } else {
      n = n * 1000 + 200;
    }
  }
  cout << n << "\n";
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  solve();

  return 0;
}


#include <iostream>
using namespace std;

int main() {
	char button;
	cin >> button;
	char answer;
	cin >> answer;
	if(button == 'Y') {
		if(answer >= 'a') {
			answer -= ('a' - 'A');
		}
	}
	else {
		if(answer <= 'Z') {
			answer += ('a' - 'A');
		}
	}
	cout << answer << "\n";
	return 0;
}

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

void Main() {
    // input
    char S;
    cin >> S;
    char T;
    cin >> T;

    // process
    char ans;
    if (S == 'Y') {
        ans = toupper(T);
    } else {
        ans = T;
    }

    // output
    cout << ans << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL <<60;
const long long  MOD = 1000000007;
typedef long long ll;
using namespace std;

ll gcd(ll m,ll n){
    if(n==0) return m;
    return gcd(n,m%n);
}

int main(){
    int n;
    cin >> n;
    n = n - 1;
    cout << n << endl;
    return 0;
}

#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define X first
#define Y second
#define nl '\n'
#define AC return 0
#define pb(a) push_back(a)
#define mst(a,b) memset(a, b, sizeof a)
#define rep(i,n) for(int i = 0; (i)<(n); i++)
#define rep1(i,n) for(int i = 1; (i)<=(n); i++)
#define scd(a) scanf("%lld", &a)
#define scdd(a,b) scanf("%lld%lld", &a, &b)
#define scs(s) scanf("%s", s)
//#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const ll INF = (ll)0x3f3f3f3f3f3f3f, MAX = 9e18, MIN = -9e18;
const int N = 1e6+10, M = 2e6+10, mod = 1e9+7, inf = 0x3f3f3f3f;
ll a[N];

int main()
{
	IOS;
	int _;
	// cin>>_;
	_ = 1;
	while(_--)
	{
		ll n;
		cin>>n;
		cout<<n-1<<nl;
	}

	AC;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  string s;
  cin >> s;
  bool ok = true;
  for(int i = 0; i < s.length(); i++) {
    if(i % 2 == 0) {
      if(s[i] >= 'a' && s[i] <= 'z') {
        continue;
      } else {
        ok = false;
      }
    } else {
      if(s[i] >= 'A' && s[i] <= 'Z') {
        continue;
      } else {
        ok = false;
      }
    }
  }
  if(ok) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <tuple>
#include <cctype>
#include <numeric>
using namespace std;
using ll = long long;
using ii = pair<int,int>;
#define F first
#define S second
#define EB emplace_back
#define REPh(i,a,b) for (int i = a; i < b; ++i)
#define REPc(i,a,b) for (int i = a; i <= b; ++i)
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)v.size()

void solve() {
    bool chk = true; string s; cin >> s;
    for (int i = 0; i < sz(s); ++i) {
        if (~i&1) {
            if (isupper(s[i])) chk = false;
        } else {
            if (islower(s[i])) chk = false;
        }
    }
    cout << (chk ? "Yes" : "No");
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    solve();
}


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll inf = 1e18;
struct Edge { int to, t, k; };

int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  x--, y--;

  vector<vector<Edge>> g(n);
  rep(i, m) {
    int a, b, t, k;
    cin >> a >> b >> t >> k;
    a--, b--;
    g[a].push_back(Edge{b, t, k});
    g[b].push_back(Edge{a, t, k});
  }

  priority_queue<pll, vector<pll>, greater<pll>> q;
  q.push(pll{0, x});

  vector<ll> d(n, 1e18);
  d[x] = 0;
  while (!q.empty()) {
    pll p = q.top();
    q.pop();
    if (d[p.second] < p.first) continue;
    for (auto a : g[p.second]) {
      ll td = p.first;
      td += (a.k - p.first % a.k) % a.k;
      td += a.t;
      if (td < d[a.to]) {
        d[a.to] = td;
        q.push(pll{td, a.to});
      }
    }
  }

  ll ans = d[y];
  if (ans == inf) ans = -1;
  cout << ans << endl;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define N 301000
#define M 601000
#define inf 1E16
typedef long long ll;

struct node{
	int v, next; ll w, kk;
}e1[M];
int head1[N];
ll dist1[N], inq1[N];
int n, m, x, y;
ll t[N], k[N];
int len = 0;

void add_edge1(int x,int y,ll w,ll kk){
	e1[++len].v=y;
	e1[len].w=w;
	e1[len].next=head1[x];
    e1[len].kk = kk;
	head1[x]=len;
	return ;
}

ll calc(ll a, ll b){
    if(a % b == 0) return a;
    else return (a / b + 1ll) * b;
}
void spfa1(){
    // cout<<inf<<endl;
	int i,j,k,u,v;
    ll w;
	queue<int> q;
	for(i = 1; i <= n; i++){
		dist1[i] = inf; inq1[i] = 0;
	}
	q.push(x);
	dist1[x] = 0;
	inq1[x] = 1;
	while(!q.empty()){
		u = q.front();
		q.pop();
		inq1[u] = 0;
		for(i = head1[u]; i != -1; i = e1[i].next){
			v = e1[i].v; w = e1[i].w;
            ll tmp = calc(dist1[u], e1[i].kk);
			if(dist1[v] > tmp + w){
				dist1[v] = tmp + w;
				if(!inq1[v]){
					q.push(v);
					inq1[v] = 1;
				}
			}
		}
	}
}

void init(){
	int i,u,v,w;
	scanf("%d%d%d%d", &n, &m, &x, &y);
	memset(head1, -1, sizeof(head1));
	for(i = 1; i <= m; i++){
		scanf("%d%d%lld%lld", &u, &v, &t[i], &k[i]);
		add_edge1(u, v, t[i], k[i]);
        add_edge1(v, u, t[i], k[i]);
	}
	return ;
}
void solve(){
	int i,j,k;
	spfa1();
	ll ans = dist1[y];
    if(ans != inf) printf("%lld\n", ans);
    else cout<<-1<<endl;
    return ;
}

int main(){
	init();
	solve();
	return 0;
}


#include <bits/stdc++.h>

#define ll long long

using namespace std;

const int N = 1e5 + 5;
const long double eps = 0.000000000000;

ll n, a[N], p[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);

	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; i++) {
		p[i] = p[i - 1] + a[i];
	}

	long double ans = 1e18 + eps;

	ans = min(ans, accumulate(a + 1,a + n + 1, (long double) 0));

	cout << fixed << setprecision(20);

	for(int i = 0; i < n; i++) {
		long double x = (a[i + 1] + eps) / 2;
		ans = min(ans, x * n - p[i + 1] + p[n] - ((n - i - 1) * x * 2));
	}

	cout << (ans + eps) / n;

}

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define mydeb(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
//#define mydeb(fmt, ...)

int main()
{
	int n;
	cin >> n;
	int x0,y0,xh,yh;
	cin >> x0 >> y0 >> xh >> yh;

	complex<double> p0(x0,y0);
	complex<double> ph(xh,yh);
	complex<double> pc=(p0+ph)/2.0;

	complex<double> r=polar(1.0,acos(-1)*2/n);
	complex<double> p1=(p0-pc)*r + pc;

	//mydeb("xc %f yc %f theta %f cosx %f cosy %f sinx %f siny %f\n",xc,yc,theta,cosx,cosy,sinx,siny);
	cout << setprecision(15) << p1.real() << " " << p1.imag() << endl;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}

const int maxn = 1000;

struct bign{
    int d[maxn], len;

	void clean() { while(len > 1 && !d[len-1]) len--; }

    bign() 			{ memset(d, 0, sizeof(d)); len = 1; }
    bign(int num) 	{ *this = num; }
	bign(char* num) { *this = num; }
    bign operator = (const char* num){
        memset(d, 0, sizeof(d)); len = strlen(num);
        for(int i = 0; i < len; i++) d[i] = num[len-1-i] - '0';
        clean();
		return *this;
    }
    bign operator = (int num){
        char s[20]; sprintf(s, "%lld", num);
        *this = s;
		return *this;
    }

    bign operator + (const bign& b){
        bign c = *this; int i;
        for (i = 0; i < b.len; i++){
        	c.d[i] += b.d[i];
        	if (c.d[i] > 9) c.d[i]%=10, c.d[i+1]++;
		}
		while (c.d[i] > 9) c.d[i++]%=10, c.d[i]++;
		c.len = max(len, b.len);
		if (c.d[i] && c.len <= i) c.len = i+1;
        return c;
    }
    bign operator - (const bign& b){
        bign c = *this; int i;
        for (i = 0; i < b.len; i++){
        	c.d[i] -= b.d[i];
        	if (c.d[i] < 0) c.d[i]+=10, c.d[i+1]--;
		}
		while (c.d[i] < 0) c.d[i++]+=10, c.d[i]--;
		c.clean();
		return c;
    }
    bign operator * (const bign& b)const{
        int i, j; bign c; c.len = len + b.len;
        for(j = 0; j < b.len; j++) for(i = 0; i < len; i++)
			c.d[i+j] += d[i] * b.d[j];
        for(i = 0; i < c.len-1; i++)
            c.d[i+1] += c.d[i]/10, c.d[i] %= 10;
        c.clean();
		return c;
    }
	bign operator += (const bign& b){
        *this = *this + b;
        return *this;
    }

    bool operator <(const bign& b) const{
        if(len != b.len) return len < b.len;
        for(int i = len-1; i >= 0; i--)
            if(d[i] != b.d[i]) return d[i] < b.d[i];
        return false;
    }
    bool operator >(const bign& b) const{return b < *this;}
    bool operator<=(const bign& b) const{return !(b < *this);}
    bool operator>=(const bign& b) const{return !(*this < b);}
    bool operator!=(const bign& b) const{return b < *this || *this < b;}
    bool operator==(const bign& b) const{return !(b < *this) && !(b > *this);}

    string str() const{
        char s[maxn]={};
        for(int i = 0; i < len; i++) s[len-1-i] = d[i]+'0';
        return s;
    }
};
bign M;
char s[103];
bool check(int len,int base)
{
	int A=1,B=0;
	bign BASE=base,t=A,sum=B;
	for(int i=len; i>=1; i--)
	{
		sum=sum+(t*(s[i]-48));
		if(sum>M) return 0;
		if(i==1) return 1;
		t=t*BASE;
		if(t>M) return 0;
	}
	return 1;
}
signed main()
{
	scanf("%s",s+1);
	int m=read(),l=strlen(s+1),g=1;
	if(l==1)
	{
		if((int)s[1]-48>m) puts("0");
		else puts("1");
		return 0;
	}
	M=m;
	for(int i=1; i<=l; i++) g=max((int)s[i]-48,g);
	++g;
	int ll=g,rr=m,ans=g-1;
	while(ll<=rr)
	{
		int mid=(ll+rr)>>1;
		if(check(l,mid)) ans=mid,ll=mid+1;
		else rr=mid-1;
	}
	printf("%lld\n",ans-g+1);
	return 0;
}

#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <stack>
#include <queue>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

bool func(string x, ll n, ll m){
	ll a=0;
	REP(i,x.size()){
		ll num = (ll)(x[i] - '0');

		if(a >= LLONG_MAX/n) return false;
		a = a*n;
		if(num >= LLONG_MAX/n) return false;
		if(a >= LLONG_MAX - num*n) return false;
		a += num;
		if(a > m) return false;
	}

	return true;
}

int main(){
	string x;
	ll m;
	cin >> x >> m;

	ll d=0;
	REP(i,x.size()){
		chmax(d, (ll)(x[i]-'0'));
	}

	if(x.size()==1){
		ll num = (ll)(x[0]-'0');
		if(num > m){
			cout << "0\n";
		}else{
			cout << "1\n";
		}
		return 0;
	}

	ll ok = d;
	ll ng = m+1;
	ll mid;

	while(ng - ok > 1){
		mid = (ok+ng)/2;

		if(func(x,mid,m)) ok = mid;
		else ng = mid;
	}

	cout << ok - d << endl;
	return 0;
}


/**
 * Author : RDP
 * There are no two words in the English language more harmful than "good job".
 * 1729 ;)
**/
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

#define endl '\n'
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#define FAST_IO              \
    ios::sync_with_stdio(0); \
    std::cin.tie(0);         \
    std::cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define PI 3.1415926535897932384626433832795
const ll MOD = 1000000007;
ll ncr(ll n, ll r)
{

    long long p = 1, k = 1;

    if (n - r < r)
        r = n - r;

    if (r != 0)
    {
        while (r)
        {
            p *= n;
            k *= r;

            long long m = __gcd(p, k);

            p /= m;
            k /= m;

            n--;
            r--;
        }
    }

    else
        p = 1;

    return p;
}
long long binpow(long long a, long long b)
{
    long long res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll score(string s)
{
    ll score = 0;
    vector<ll> m(10);
    for (char c : s)
    {
        if (c != '#')
        {
            m[c - '0']++;
        }
    }
    for (int i = 1; i <= 9; i++)
    {
        score += i * binpow(10, m[i]);
    }
    return score;
}
bool wins(string s, string t)
{
    return score(s) > score(t);
}
void test_case()
{
    ll k;
    double event = 0, total_event = 0;
    cin >> k;
    vector<ll> rem(10, k);
    rem[0] = 0;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i <= 3; i++)
        rem[s[i] - '0']--, rem[t[i] - '0']--;
    ll score_s = score(s), score_t = score(t);
    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= 9; j++)
        {
            if (i != j)
            {
                double x;
                x = max(0LL, rem[i] * rem[j]);
                if (wins(s + char('0' + i), t + char('0' + j)))
                    event += x;
                total_event += x;
            }
        }
    }
    for (int i = 1; i <= 9; i++)
    {
        double x;
        x = max(0LL, (rem[i] - 1) * rem[i]);
        if (wins(s + char('0' + i), t + char('0' + i)))
            event += x;
        total_event += x;
    }
    cout << event / total_event;
    return;
}
int main()
{
    FAST_IO
    int t = 1;
    //cin >> t;
    while (t--)
        test_case();
    return 0;
}

#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define ROF(i, a, b) for (int i = a; i >= b; --i)
#define NEXT(i, u) for (int i = h[u]; i; i = e[i].u)
const int INF = 2e9;
const int K = 1e5 + 7;

int Max(const int &a, const int &b) {return a > b ? a : b;}
int Min(const int &a, const int &b) {return a > b ? b : a;}

int sum[20], tot[20];
int k, n;
double sy;
double ans, sm;
char s[20], t[20];

int po(int x){
    int ans = 1;
    FOR (i, 1, x) ans *= 10;
    return ans;
}

int main(){
    scanf("%d", &k);
    sy = 9 * k - 8;
    scanf(" %s %s", s, t);
    n = strlen(s);
    FOR (i, 0, 3){
        int c = s[i] - '0', cc = t[i] - '0';
        ++sum[c];
        ++tot[cc];
    }
    FOR (i, 1, 9){
        FOR (j, 1, 9){
            if (i == j){
                if (sum[i] + tot[j] + 2 <= k) ++sum[i], ++tot[j];
                else continue;
            }
            else {
                if (sum[i] + tot[i] + 1 <= k && sum[j] + tot[j] + 1 <= k) ++sum[i], ++tot[j];
                else continue;
            }
            int sc1 = 0, sc2 = 0;
            FOR (l, 1, 9){
                sc1 += l * po(sum[l]);
                sc2 += l * po(tot[l]);
            }
            --sum[i];
            --tot[j];
            if (sc1 > sc2){
                if (i == j) ans += (1.0 * (1.0 * k - sum[i] - tot[i]) / sy) * (1.0 * (1.0 * k - sum[j] - tot[j] - 1) / (sy - 1));
                else ans += (1.0 * (1.0 * k - sum[i] - tot[i]) / sy) * (1.0 * (1.0 * k - sum[j] - tot[j]) / (sy - 1));
            }
        }
    }
    printf("%.16lf\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define MOD1 998244353
#define ceil(x, y) ((x)%(y))==0? ((x)/(y)) : ((x)/(y)+1)
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define int long long
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, int, hash<int>> ht; // while using, comment #define int long long  */

void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
using namespace std;
int power(int x, int y, int m){
    if(y == 0) return 1;
    if(y & 1) return x * power(x, y-1, m) % m;
    else{
        int p = power(x, y / 2, m);
        return p * p % m;
    }
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("in7.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int T=1;
    // cin >> T;
    FOR1(tt, T){
        // cout << "Case #" << tt << ": ";
        int n, m; cin >> n >> m;
        /*Observe X % M == (X - kM) % M */
        cout << (power(10, n, m*m) / m) % m;
        cout << '\n';
    }
    return 0;
}

#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long int
#define f first
#define s second
using namespace  std;
ll mod=1e9+7;
ll expo(ll base,ll power,ll m)
{
    ll res=1;
    while(power)
    {
        if(power&1)res*=base,res%=m;
        base*=base,base%=m;
        power/=2;
    }
    return res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    m*=m;
    ll num=expo(10,n,m);
   // cout<<num<<endl;
    m=sqrt(m);
    ll rem=(num/m);
    cout<<rem%m<<endl;
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

#define int long long
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define precise(x) fixed << setprecision(x)

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    if(a == 0) return 0;
    b %= (M - 1);  //M must be prime here

    int res = 1;

    while(b > 0)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }

    return res;
}

unordered_map<int,int> mp;

void solve()
{
    int n,m;
    cin >> n >> m;

    pii a[m];
    f(i,m) cin >> a[i].F >> a[i].S;
    sort(a,a+m);

    mp[n] = 1;

    int ptr = 0;
    int cur_row = 0;

    while(ptr < m)
    {
        cur_row = a[ptr].F;

        unordered_map<int,int> prev_data;
        vector<int> upd;

        while(ptr < m && a[ptr].F == cur_row)
        {
            upd.pb(a[ptr].S);
            ptr++;
        }

        for(auto x : upd)
        {
            prev_data[x - 1] = mp[x - 1];
            prev_data[x] = mp[x];
            prev_data[x + 1] = mp[x + 1];
        }

        for(auto x : upd)
        {
            mp[x] = (prev_data[x-1] || prev_data[x+1]);
        }
    }

    int res = 0;
    for(auto x : mp) res += x.S;
    cout << res;
}

signed main()
{
    fast;

    int t = 1;

//    cin >> t;

    while(t--)

    solve();
}

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define int long long
#define eb emplace_back
#define maxll (1ll<<62)
#define minll -(1ll<<62)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define show(X) for(auto aa:X)cout<<aa<<' ';cout<<'\n';
//const double PI=3.1415926535898;
//const int mod=1000000007;
/**********************************************************************/

int32_t main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);//cout << setprecision(15);

	int h, w, x, y;
	cin >> h >> w >> x >> y;
	vector<string> v(h);
	rep(i, 0, h)
	{
		cin >> v[i];
	}
	int cnt = 0;
	if (v[x - 1][y - 1] == '.')
		cnt++;
	int i;
	for (i = x - 2; i >= 0; i--)
	{
		if (v[i][y - 1] == '#')
			break;
		cnt++;
	}
	for (i = x; i < h; i++)
	{
		if (v[i][y - 1] == '#')
			break;
		cnt++;
	}
	for (i = y - 2; i >= 0; i--)
	{
		if (v[x - 1][i] == '#')
			break;
		cnt++;
	}
	for (i = y; i < w; i++)
	{
		if (v[x - 1][i] == '#')
			break;
		cnt++;
	}
	cout << cnt;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define ll long long

const ll OO = 0x3f3f3f3f;
const ll mod =   1e9 + 7;
const double pi = 3.14159265359;

//freopen("window.in", "r", stdin);
//freopen("output.out", "w", stdout);
void skrrrt() {
    ios_base::sync_with_stdio(0), cin.tie(0);
}
//###############################Spaggetti############################
const int N=100009;
int color[N];
vector<vector<int>>g(N);
int n;
map<int,int>mp;
vector<int>ans;
bool vis[N];
void dfs(int node){
    vis[node]=1;
    if(mp[color[node]]==0)ans.push_back(node);
    mp[color[node]]++;
    for(auto child:g[node]){
        if(!vis[child]){
            dfs(child);
        }

    }
    mp[color[node]]--;
}
int main(){
    skrrrt();
    cin>>n;
    for(int i=1;i<=n;i++)cin>>color[i];
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1);
    sort(ans.begin(),ans.end());
    for(auto i:ans)
        cout<<i<<"\n";

}

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
// const int mod = 998244353;

int n;
vi c;
vvi g;
map<int, int> mp;
vector<bool> ans;
vi used;

void dfs(int v) {
  // cout << v << endl;
  used[v] = 1;
  if (mp[c[v]]) ans[v] = false;
  mp[c[v]]++;
  for (int e : g[v]) {
    if (used[e]) continue;
    dfs(e);
  }
  mp[c[v]]--;
}

int main() {
  cin >> n;
  c.resize(n);
  g.resize(n);
  used.resize(n);
  ans = vector<bool>(n, true);
  rep(i,n) cin >> c[i];
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(0);
  rep(i, n) if (ans[i]) cout << i+1 << endl;
  // for (auto x : mp) printf("%d : %d\n", x.first, x.second);
}


#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define fast_input ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7

#define inf std::numeric_limits<int>().max()
#define ll long long

using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }
    for(int i=0; i<n; i++) {
        cin >> b[i];
    }
    vector<int> v(n);
    for(int i=0; i<n; i++) {
        v[i] = a[i] - b[i];
    }
    vector<pair<int, int>> x, y;
    for(int i=0; i<n; i++) {
        if (i%2) x.push_back({v[i], i});
        else y.push_back({v[i], i});
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    ll ans = 0;
    for(int i=0; i<x.size(); i++) {
        if (x[i].first + y[i].first > 0) ans += a[x[i].second] + a[y[i].second];
        else ans += b[x[i].second] + b[y[i].second];
    }
    cout << ans << endl;
}

#include <bits/stdc++.h>
#define Rep(i,n) for(int i=0;i<n;i++)
#define Repr(i,n) for(int i=n;i>=0;i--)
#define For(i,m,n) for(int i=m;i<n;i++)
#define Inf 1LL<<60
#define All(v) v.begin(),v.end()
#define Mod (ll)(1e9+7)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;

int main()
{
    int n,k;
    vl a{};
    cin>>n>>k;
    a.reserve(n);
    Rep(i,n-1){
        a.push_back(i+1);
    }
    //cout<<a.size()<<endl;
    ll t[n][n]={};
    Rep(i,n){
        Rep(j,n){
            cin>>t[i][j];
        }
    }
    int tmp=0,count=0;
    do{
        tmp=0;
        Rep(i,n-1){
            tmp+=t[a[i]][a[i+1]];
        }
        tmp+=t[0][a[0]];
        tmp+=t[a[n-1]][0];
        //cout<<tmp<<" ";
        if(tmp==k){
            count+=1;
            //cout<<tmp<<" ";
        }
    }while(next_permutation(a.begin(),a.end()));
    cout<<count<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int a;
    bool isPermutation = true;
    cin >> a;

  int b[a];
    for(int i = 0; i < a; i++){
        cin >> b[i];
    }
    sort(b, b + a);
    for(int i = 0; i < a; i++){
        if(b[i] != i + 1){
            isPermutation = false;
        }
    }

   if(isPermutation){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


/**
 *    author:     stein
 *    created:    2020.11.27 12:14:31
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long s, p;
  cin >> s >> p;
  for (long long i = 1; i <= 1000000; i++) {
    if (i * (s - i) == p) {
      cout << "Yes" << '\n';
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

int main(){
  ll s, p;
  cin >> s >> p;
  bool can = false;
  for(ll x = 1; x*x <= p; x++) {
    if(p % x == 0 and x + p/x == s) can = true;
  }
  cout << (can ? "Yes": "No") << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(int i=(l); i<(r); i++)
#define REP(i,n) FOR(i,0,n)
#define endl "\n"
#define debug(x) cout<<x<<endl;
typedef long long ll;
static const int INF = 1e9+7;

bool equal(double a, double b){
    double eps = 1e-4;
    if(fabs(a - b) <= eps) return true;
    else return false;
}

int main(){
    int N;
    cin>>N;
    vector<int> X(N),Y(N);
    REP(i,N){
        cin>>X[i]>>Y[i];
    }

    bool flag = false;

    REP(i,N){
        FOR(j,i+1,N){
            if(X[i] == 0 && X[j] == 0){
                FOR(k,j+1,N){
                    if(X[k] == 0){
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                }
            }
            else{
                double dif = (Y[j] - Y[i]) / (double)(X[j] - X[i]);
                FOR(k,j+1,N){
                    if((dif == (double)(Y[k] - Y[j])/ (double)(X[k] - X[j]))){
                        cout<<"Yes"<<endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout<<"No"<<endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
#define rep(i,b,e) for(int i=b;i<e;i++)
#define per(i,e,b) for(int i=e;i>b;i--)
const int maxn = 5e5+5;

void solve() {
	ll s,p; cin >> s >> p;
	for(ll i=1; i*i <= p; i++) {
		if (p%i==0 && (p/i + p/(p/i)) == s) {
			cout << "Yes\n";
			return;
		}
		if (p%(p/i)==0 && (p/i + p/(p/i)) == s) {
			cout << "Yes\n";
			return;
		}
	}
	cout << "No\n";
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("/home/l4wenwen/data/in", "r", stdin);
	//freopen("~/out", "w", stdout);
#endif
	//int t; cin >> t; while(t--)
		solve();
	return 0;
}


#include <bits/stdc++.h>
#define rep(i, a, b)   for(int i = a; i <= b; ++i)
#define repr(i,a,b)    for(int i = a ; i >= b; --i)
#define NAME           "CAMEL"
#define pb             push_back
#define mp             make_pair
#define EL             cout << '\n'
#define cqtshadow      int main
#define fillchar(a,x)  memset(a, x, sizeof (a))
#define faster         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
typedef int64_t        i64;
typedef vector<int>    vi;
typedef vector<i64>    vl;
typedef pair<int, int> ii;
typedef pair<i64, i64> iil;
const i64 oo  =  1e18;
const int inf =  1e9;
const int mod =  1e9 + 7;
const int N   =  1e5 + 7;
const int M   =  1e6 + 7;
void file() {freopen ( NAME ".inp", "r", stdin ); freopen ( NAME ".out", "w", stdout ); freopen ( NAME ".err", "w", stderr);}

int n, m, w[N], l[N], v[N], p[N], H[1 << 8], s[1 << 8];
i64 ans = oo, dp[8];

bool checkbit(int mask, int x) {
        return ((mask >> x) & 1);
}

void onbit(int &mask, int x) {
        mask = (mask | (1 << x));
}

cqtshadow () {
//        file();
        faster
        cin >> n >> m;
        rep(i, 0, n - 1) cin >> w[i], p[i] = i;
        rep(i, 0, m - 1) cin >> l[i] >> v[i];

        if(*min_element(v, v + m) < *max_element(w, w + n)) return cout << -1, 0;

        int limit = (1 << n) - 1;

        // weight of every subset
        rep(mask, 1, limit)
        rep(i, 0, n - 1)
                if(checkbit(mask, i)) s[mask] += w[i];

        //calculate the at least separate length of every subset
        rep(mask, 1, limit)
        rep(i, 0, m - 1) {
                if(s[mask] > v[i])
                        H[mask] = max(H[mask], l[i]);
        }

        // go through all permutation
        //dp[i] is the "have to separate length" from 1 -> i

        do {
                memset(dp, 0, sizeof dp);
                rep(i, 0, n - 1) {
                        int mask = 0;
                        repr(j, i, 0) {
                                onbit(mask, p[j]);
                                dp[i] = max(dp[i], dp[j] + H[mask]);
                        }
                }
                ans = min(ans, dp[n - 1]);
        } while(next_permutation(p, p + n));

        cout << ans;
}

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  cin >> n >> m;

  vector<int> w(n);
  vector<pair<int, int>> p(m);

  int mn = INT_MAX;
  for (int i = 0; i < n; ++i) cin >> w[i];
  for (int i = 0; i < m; ++i) {
    cin >> p[i].second >> p[i].first;
    mn = min(mn, p[i].first);
  }

  if (*max_element(w.begin(), w.end()) > mn) {
    cout << -1 << '\n';
    return 0;
  }

  p.emplace_back(0, 0);
  p.emplace_back(1e9, 0);

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

  for (int i = 1; i < (int)p.size(); ++i) {
    p[i].second = max(p[i].second, p[i - 1].second);
  }

  auto getlen = [&](int wei) {
    int j = lower_bound(p.begin(), p.end(), make_pair(wei, 0)) - p.begin() - 1;
    return p[j].second;
  };

  auto solve = [&]() {
    vector<int> dist(n, 0);
    for (int i = 1; i < n; ++i) {
      int sum = w[i];
      for (int j = i - 1; j >= 0; --j) {
        sum += w[j];
        dist[i] = max(dist[i], getlen(sum) + dist[j]);
      }
    }

    return dist[n - 1];
  };

  int ans = solve();
  while (next_permutation(w.begin(), w.end())) {
    ans = min(ans, solve());
  }

  cout << ans << '\n';
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 998244353
#define PI 3.141592653589793238
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void solve() {
    ll n;
    cin>>n;
    vector<ll> vec(n);
    for(auto& it : vec) cin>>it;

    sort(all(vec));

    ll last = vec[0];
    ll sum = vec[0]*vec[0];
    for(int i = 1; i < n; ++i) {
        last = (last * 2 + vec[i] - vec[i-1] + mod) % mod;
        sum = ((sum%mod) + (last%mod) * (vec[i])) % mod;
    }
    cout<<sum%mod<<endl;
}

int32_t main()  {
    fastio
    int t = 1;
    //cin>>t;
    while(t--)
        solve();
}

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
const ll mo=998244353;

int dp[3030][3030];

void solve() {
	int i,j,k,l,r,x,y; string s;

	cin>>N>>K;
	dp[K][K]=1;

	for(i=K;i<N;i++) {
		for(y=1;y<=N;y++) if(dp[i][y]) {
			for(x=1;x<=y&&i+x<=N;x++) {
				dp[i+x][2*x]+=dp[i][y];
				if(dp[i+x][2*x]>=mo) dp[i+x][2*x]-=mo;
			}
		}
	}
	ll ret=0;
	FOR(i,N+1) ret+=dp[N][i];
	cout<<ret%mo<<endl;

}

int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


#include<iostream>
using namespace std;
#include<vector>
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const ll E18 = 1000000000000000000LL;

int main() {
  int N,i,j,k;
  ll X;
  cin>>N>>X;
  vi A(N);
  for (i=0;i<N;i++) cin>>A[i];

  ll ans = E18;
  for (int C=1;C<=N;C++) {
    vvvi dp(N+1,vvi(C+1,vi(C,-1)));
    dp[0][0][0]=0;
    for (i=1;i<=N;i++) {
      for (j=1;j<=min(i,C);j++) {
        for (k=0;k<C;k++) {
          int nk = (k+A[i-1])%C;
          if (dp[i-1][j][nk]>=0) dp[i][j][nk] = max(dp[i][j][nk], dp[i-1][j][nk]);
          if (dp[i-1][j-1][k]>=0) dp[i][j][nk] = max(dp[i][j][nk], dp[i-1][j-1][k]+A[i-1]);
        }
      }
    }
    // printf("dp[%d][%d][%d] = %d\n", N, C, (int)(X%C), dp[N][C][(int)(X%C)]);
    if (dp[N][C][(int)(X%C)]>0) {
      ans = min(ans, (X-dp[N][C][(int)(X%C)])/C);
    }
  }
  cout<<ans<<endl;
  return 0;
}

#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

//#include <atcoder/all>
// using namespace atcoder;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, y) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), y))
#define Upper_bound(v, y) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), y))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, x;
  cin >> n >> x;

  vvvll dp(n + 1, vvll(n + 1, vll(n + 1, -1)));
  repLRE(i, 1, n) dp[0][i][0] = 0;
  rep(_, n) {
    ll a;
    cin >> a;
    vvvll ndp = dp;
    rep(i, n) repLRE(j, 1, n) rep(k, j) {
      if (dp[i][j][k] != -1) {
        ll ni = i + 1;
        ll nk = (dp[i][j][k] + a) % j;
        chmax(ndp[ni][j][nk], dp[i][j][k] + a);
      }
    }
    swap(ndp, dp);
  }

  ll ans = x;
  repLRE(i, 1, n) rep(k, i) {
    ll v = x - dp[i][i][k];
    if (dp[i][i][k] != -1 && v % i == 0) {
      ll tmp = v/i;
      chmin(ans, tmp);
    }
  }

  cout << ans << endl;

  return 0;
}


/*

 ALLAH IS ALMIGHTY              ******BISMILLAHIR RAHMANIR RAHIM.******              ALLAH IS ALMIGHTY
                                    ```````````````````````````````
                                        AUTHOR: ANISUR RAHAMAN
                                            BSMRSTU(SHIICT)
                                                ID:017

                            ............LET's START OUR JOURNEY.............

*/
#include <bits/stdc++.h>

#define I_O ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

//~~~~~~~~~~~~ Sort Form Of Long~~~~~~~~~~~//
#define ll long long int
#define lls int64_t
#define ld long double
#define db double
#define ull unsigned long long int

//~~~~~~~~~~~~~~Pair~~~~~~~~~~~~~~~~~~//
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<db,db>
#define psi pair<string,int>
#define vi vector<int>
#define vl vector<ll>
#define vd vector<db>
#define vs vector<string>
#define vb vector<bool>
#define vpi vector<pii>
#define vpl vector<pll>
#define vpd vector<pdd>
#define vpsi vector<psi>

//~~~~~~~~~~~~~~Vector~~~~~~~~~~~~~~~~~//
#define pb push_back
#define pf push_front
#define MP make_pair
#define in insert
#define ff first
#define ss second
#define al(v) v.begin(),v.end()
#define alr(v) v.rbegin(), v.rend()
#define srt(v) sort(al(v))
#define srtr(v) sort(al(v), greater<int>());
#define len(x) ((ll)(x).length())
#define sz(x) ((ll)(x).size())
#define rev(v) reverse(al(v))
#define btcnt(n) __builtin_popcount(n)
#define acl(v, n) accumulate(al(v), n)
#define eb emplace_back
#define lb(v, kk) lower_bound(al(v), kk)
#define ub(v, kk) upper_bound(al(v), kk)
#define tpu(str) transform(al(str), str.begin(), ::toupper)
#define tpl(str) transform(al(str), str.begin(), ::tolower)
#define cignr cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define mxv(v) *max_element(al(v))
#define mnv(v) *min_element(al(v))

const int MOD = 1e9 + 7;
const ll INF = 2e18;
const int mxn = 2e9 + 9;
const int mxd = 2e5 + 5;

//~~~~~~~~~~~~~~~~~~Function~~~~~~~~~~~~~~~~~~~~//
lls gcd(lls a, lls b){
    if(b == 0LL) return a;
    return gcd(b, a % b);
}

lls lcm(lls a, lls b){
    return (a / gcd(a, b) * b);
}
//~~~~~~~~~~~~~~~Loops and Short~~~~~~~~~~~~~~~~//

#define PI acos(-1)
#define C continue
#define B break
#define off return 0
#define N '\n'
#define WT(something) auto az = something; cout << az << N;
#define WTS(something) cout << something << N;
#define rep(i, n) for(lls i = 0; (lls)i < n; i++)
#define repn(i, a, b) for(lls i = (lls)(a); i < (lls)(b); i++)
#define repr(i, a, b) for(lls i = (lls)(a) - 1; i >= (lls)(b); i--)
#define test_case() int T; T = 1; while(T--)

using namespace std;

// ===================================~~~~~~ SOLUTION STARTS HERE ~~~~~~=================================== //

void Run_Case()
{
    string str;
    cin >> str;
    string rev = string(alr(str));
    if (str == rev) {
        cout << "Yes" << N;
        return;
    }

    int l = len(str);
    int f = 0, k = 0;
    while (1) {
        string ka = "0" + str;
        string ra = string(alr(ka));
        if (ka == ra) {
            cout << "Yes" << N;
            return;
        }

        if (k == l) B;
        k++;
        str = ka;
    }

    cout << "No" << N;
}

int main()
{
    I_O
    test_case()
    {
        Run_Case();
    }
    off;
}

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

static void removeTrailingCharacters(std::string &str, const char charToRemove) {
    str.erase (str.find_last_not_of(charToRemove) + 1, std::string::npos );
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll n;
    cin>>n;
    string temp=to_string(n);
    removeTrailingCharacters(temp,'0');
    string temp2=temp;
    reverse(temp2.begin(),temp2.end());
    if(temp==temp2){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

template<class T> struct BIT {  // 0-origin
	vector<T> dat;
	int N;
	BIT(){}
	BIT(int _N){
		N=_N;
		dat.assign(N,0);
	}
	// sum [0,i)
	T sum(int i){
		int ret = 0;
		for(--i; i>=0; i=(i&(i+1))-1) ret += dat[i];  // 可換群の演算
		return ret;
	}
	// sum [i,j)
	T sum(int i, int j) { return sum(j) - sum(i); }  // 可換群の逆元
	// add x to i
	void add(int i, T x) { for(; i < N; i|=i+1) dat[i] += x; }  // 可換群の演算
};

/*
*/

struct d{ll x,y;};

ll ans=0;
ll h,w,m;
set<ll> v[200010],v2[200010];

int main(void){
	cin>>h>>w>>m;
	rep(i,m){
		ll x,y;
		cin>>x>>y;
		v[x].insert(y);
		v2[y].insert(x);
	}
	reg(i,1,h)v[i].insert(w+1);
	reg(i,1,w)v2[i].insert(h+1);

	// 右　下
	reg(i,1,h){
		ll t = *v[i].begin();
		ans+=t-1;
		if(t==1)break;
	}

	BIT<ll> bit(200010);
	reg(i,*v2[1].begin(),h)bit.add(i,1);  // これ以降は通れてないので
	reg(i,1,w){
		ll t = *v2[i].begin();
		ans += bit.sum(t);
		for(auto itr = v2[i].begin(); itr!=v2[i].end(); itr++){
			ll a = *itr;
			if(bit.sum(a,a+1)==0)bit.add(a,1);
		}
		if(t==1)break;
	}
	cout<<ans<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int N=2e5+5;
int n,m,k;
int c[N];
vector<int>v[N];
int lowbit(int x){return x&(-x);}
int query(int i){
	int res=0;
	while(i){
		res+=c[i];
		i-=lowbit(i);
	}
	return res;
}
int getsum(int l,int r){return query(r)-query(l-1);}
void add(int i,int x){
	while(i<=m){
		c[i]+=x;
		i+=lowbit(i);
	}
}
void sub(int i){
	if(getsum(i,i)==1)	add(i,-1);
}
int main(){
	scanf("%d%d%d",&n,&m,&k);
	int miny=m+1,minx=n+1;
	for(int i=1;i<=k;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		if(x==1)	miny=min(miny,y);
		if(y==1)	minx=min(minx,x);
		v[x].push_back(y);
	}
	for(int i=1;i<=minx;i++)	sort(v[i].begin(),v[i].end());
	for(int i=1;i<=m;i++)	add(i,1);
	for(int i=miny;i<=m;i++)	sub(i);
	LL res=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<v[i].size();j++)	sub(v[i][j]);
		if(i<minx){
			if(v[i].empty())	res+=m;
			else{
				res+=v[i][0]-1;
				res+=getsum(v[i][0]+1,m);
			}
		}
		else	res+=getsum(1,m);
	}
	printf("%lld\n",res);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
using namespace std;
ll F[200009],S[200009],sz[200009];
map<ll,ll> mp;
vector<ll> G[100009];
bool cmp(const ll &a,const ll &b)
{
    return S[a]-F[a] > S[b]-F[b];
}
void DFS(ll u)
{
    vector<ll> tp,bd;
    ll i;
    sz[u] = 1;
    F[u] = 1;
    S[u] = 0;
    for(auto v : G[u])
    {
        DFS(v);
        sz[u] += sz[v];
        if(sz[v] % 2 == 0)
        {
            if(S[v] >= F[v])
            {
                S[u] += S[v];
                F[u] += F[v];
            }
            else
            {
                bd.push_back(v);
            }
        }
        else
        {
            tp.push_back(v);
        }
    }
    sort(tp.begin(),tp.end(),cmp);
    for(i = 0;i < tp.size();i++)
    {
        if(i & 1)
        {
            F[u] += S[tp[i]];
            S[u] += F[tp[i]];
        }
        else
        {
            F[u] += F[tp[i]];
            S[u] += S[tp[i]];
        }
    }
    for(auto x : bd)
    {
        if(sz[u] % 2 == 1)
        {
            F[u] += F[x];
            S[u] += S[x];
        }
        else
        {
            F[u] += S[x];
            S[u] += F[x];
        }
    }

}
int main()
{
    ll N,Q,M,i,j,k,t,ans,l,r;
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> N;
    for(i = 2;i <= N;i++)
    {
        cin >> t;
        G[t].push_back(i);
    }
    DFS(1);
    cout << F[1] << endl;
}

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

ll n;
vvl G;
vl dp;
vl Size;  // Size[v] : vの部分木のサイズ

void dfs1(ll v, ll p = -1) {
    Size[v] = 1;
    for(ll u : G[v]) {
        if(u == p) {
            continue;
        }
        dfs1(u, v);
        Size[v] += Size[u];
    }
}

void dfs2(ll v, ll p = -1) {
    dp[v] = 1;
    ll x = 0;
    vl vec;
    for(ll u : G[v]) {
        if(u == p) {
            continue;
        }
        dfs2(u, v);
        if(Size[u]%2 == 0) {
            if(dp[u] < 0) {
                dp[v] += dp[u];
            }
            else {
                x += dp[u];
            }
        }
        else {
            vec.pb(dp[u]);
        }
    }
    sort(all(vec));
    ll k = vec.size();
    rep(i, k) {
        if(i%2 == 0) {
            dp[v] += vec[i];
        }
        else {
            dp[v] -= vec[i];
        }
    }
    if(k%2 == 0) {
        dp[v] += x;
    }
    else {
        dp[v] -= x;
    }
}

int main() {

    cin >> n;

    G.resize(n);
    exrep(i, 1, n-1) {
        ll p;
        cin >> p;
        p--;
        G[i].pb(p);
        G[p].pb(i);
    }

    Size.resize(n);
    dfs1(0);

    dp.resize(n);
    dfs2(0);

    out((n + dp[0])/2);
    re0;
}


#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define RSort(a) sort(a.rbegin(), a.rend())
#define Output(a) printf("%d %s", a, "\n")

typedef long long int ll;
typedef vector<int> vi;
typedef vector<long long> vll;

const ll INF = 0x1fffffffffffffff;
const ll MOD = 1000000007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    ll n; cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    vll b(200);
    rep(i, n) b[a[i] % 200]++;
    ll ans = 0;
    rep(i, 200){
        if(b[i] >= 2){
            ans += (b[i] * (b[i] - 1)) / 2;
        }
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    solve();
}

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

ll gcd(ll a,ll b){
    return b==0?a:gcd(b,a%b);
}

const int L=72;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll A,B;
  cin>>A>>B;

  vector<ll> v;
  for(ll i=A;i<=B;i++) v.push_back(i);
  int V=v.size();

  vector<int> is_prime(L+1,1);
  is_prime[0]=0;
  is_prime[1]=0;
  for(int i=2;i<=L;i++){
      if(is_prime[i]==0) continue;
      for(int j=2;i*j<=L;j++) is_prime[i*j]=0;
  }
  vector<int> primes;
  for(int i=2;i<=L;i++) if(is_prime[i]) primes.push_back(i);
  int P=primes.size();

  vector<vector<ll>> dp(V+1,vector<ll> (1<<P,0));
  dp[0][0]=1;
  for(int i=0;i<V;i++){
      for(int j=0;j<(1<<P);j++){
          ll value=dp[i][j];
          if(value==0) continue;
          dp[i+1][j]+=value;
          {
              int state=0;
              rep(k,P) if(v[i]%primes[k]==0) state+=(1<<k);
              if((j&state)==0) dp[i+1][j^state]+=value;
          }
      }
  }

  ll ans=0;
  rep(j,(1<<P)) ans+=dp[V][j];
  cout<<ans<<endl;

  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int i = 1;
  int ans = 0;

  while(ans < N){
    ans += i;
    i++;
  }
  cout << i - 1;
}

#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i,j,k,m,n,t;
    vector<int>a;
    a.push_back(0);
    for(i=1;i<=50000;i++)
    {
        a.push_back((i*(i+1))/2);
    }
    cin>>n;
    auto low1 = std::lower_bound(a.begin(), a.end(), n);
    cout<<(low1 - a.begin())<<endl;
    return 0;
}


/**
 * @author Macesuted (macesuted@qq.com)
 * @copyright Copyright (c) 2021
 */

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

#define int long long
#define mod 1000000007
// #define mod 998244353
#define maxn 200005

long long fac[maxn], inv[maxn];

long long power(long long a, long long x) {
    long long ans = 1;
    while (x) {
        if (x & 1) ans = ans * a % mod;
        a = a * a % mod;
        x >>= 1;
    }
    return ans;
}

inline long long C(int n, int m) { return fac[n] * inv[m] % mod * inv[n - m] % mod; }
void INIT(void) {
    fac[0] = inv[0] = 1;
    for (register int i = 1; i < maxn; i++) fac[i] = fac[i - 1] % mod;
    inv[maxn - 1] = power(fac[maxn - 1], mod - 2);
    for (register int i = maxn - 2; i; i--) inv[i] = inv[i + 1] * (i + 1) % mod;
    return;
}

typedef pair<int, int> pii;

map<int, int> rec, cac;

pii a[maxn];

int n, m;

void work(void) {
    // INIT();
    cin >> n >> m;
    for (register int i = 1; i <= m; i++) cin >> a[i].first >> a[i].second;
    sort(a + 1, a + m + 1);
    rec[n] = 1;
    for (register int i = 1, last = -1; i <= m; i++) {
        if (last != a[i].first) {
            for (auto i : cac) rec[i.first] = i.second;
            cac.clear();
            last = a[i].first;
        }
        cac[a[i].second] = rec[a[i].second - 1] + rec[a[i].second + 1];
    }
    for (auto i : cac) rec[i.first] = i.second;
    int answer = 0;
    for (auto i : rec)
        if (i.second) answer++;
    cout << answer << endl;
    return;
}

signed main() {
    ios::sync_with_stdio(false);
    cout << setiosflags(ios::fixed) << setprecision(3) << endl;
    int _ = 1;
    // cin >> _;
    while (_--) work();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
ll N;
ll par[400005];
ll rank_[400005];
bool c[400005];
void init(ll n_){
for(ll i=0;i<n_;i++){
par[i]=i;rank_[i]=0;
}
}
ll find(ll x){
if(par[x]==x)return x;
  return par[x]=find(par[x]);
}
void unite(ll x,ll y){
x=find(x);y=find(y);
  if(x==y){c[x]=true;return;}
  if(rank_[x]<rank_[y]){
  par[x]=y;c[y]|=c[x];
  }else{
   par[y]=x;c[x]|=c[y];if(rank_[x]==rank_[y])rank_[x]++;
  }
}
int main(){
 cin>>N;set<ll>S;
  vector<P>A(N);
  for(ll i=0;i<N;i++){
  ll a,b;cin>>a>>b;S.insert(a);S.insert(b);
    A[i]=P(a,b);
  }ll I=0;map<ll,ll>mp;
  for(auto x:S){mp[x]=I;I++;}
  init(I);
  for(ll i=0;i<N;i++){
  ll a=mp.at(A[i].first);
    ll b=mp.at(A[i].second);
    unite(a,b);
  }ll ans=I;
  for(ll i=0;i<I;i++)
    if(par[i]==i){
    if(!c[i])ans--;
    }cout<<ans<<endl;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define reg register
typedef long long ll;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
static char buf[1<<21],*p1=buf,*p2=buf;
inline int read(void){
	reg char ch=getchar();
	reg int res=0;
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)) res=10*res+(ch^'0'),ch=getchar();
	return res;
}

const int MAXN=2e5+5;

int n;
vector<int> G[MAXN];
int fa[MAXN],dep[MAXN];

inline void dfs1(reg int u,reg int father){
	fa[u]=father;
	dep[u]=dep[father]+1;
	for(int v:G[u])
		if(v!=father)
			dfs1(v,u);
	return;
}

bool tag[MAXN];
int tim,dfn[MAXN];

inline void dfs2(reg int u,reg int father){
	dfn[u]=++tim;
	reg int son=0;
	for(int v:G[u])
		if(v!=father){
			if(!tag[v])
				dfs2(v,u);
			else
				son=v;
		}
	if(son)
		dfs2(son,u);
	++tim;
	return;
}

int main(void){
	n=read();
	for(reg int i=1;i<n;++i){
		static int u,v;
		u=read(),v=read();
		G[u].push_back(v),G[v].push_back(u);
	}
	dfs1(1,0);
	reg int rt=1;
	for(reg int i=2;i<=n;++i)
		if(dep[i]>=dep[rt])
			rt=i;
	dfs1(rt,0);
	reg int ptr=1;
	for(reg int i=2;i<=n;++i)
		if(dep[i]>=dep[ptr])
			ptr=i;
	while(ptr)
		tag[ptr]=true,ptr=fa[ptr];
	dfs2(rt,0);
	for(reg int i=1;i<=n;++i)
		printf("%d%c",dfn[i],i==n?'\n':' ');
	return 0;
}

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

typedef pair<int,int> pii;
const int N=105;
const double eps=1e-7;
int n,m;
int X[N*3],Y[N*3],p[N*3];
pii XY[N];
pair<double,pii> e[N*N*9];

int fp(int x){
	return (x==p[x])?x:(p[x]=fp(p[x]));
}

void lnk(int x,int y){
	x=fp(x);y=fp(y);
	p[x]=y;
}

bool check(double d){
	for(int i=1;i<=n*3;i++) p[i]=i;
	for(int i=1;i<n;i++){
		lnk(i+n,i+1+n);
		lnk(i+n*2,i+1+n*2);
	}
	for(int i=1;i<=m;i++) if(e[i].first<d) lnk(e[i].second.first,e[i].second.second);
	for(int i=1;i<=n;i++) if(fp(i+n)==fp(i+2*n)) return false;
	return true;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",X+i,Y+i);
		XY[i]=make_pair(X[i],Y[i]);
	}
	sort(XY+1,XY+1+n);
	for(int i=1;i<=n;i++){
		X[i]=XY[i].first;
		Y[i]=XY[i].second;
	}
	for(int i=1;i<=n;i++){
		X[i+n]=X[i+2*n]=X[i];
		Y[i+n]=-100;
		Y[i+2*n]=100;
	}
	for(int i=1;i<=n*3;i++) for(int j=i+1;j<=n*3;j++) e[++m]=make_pair(1.0*sqrt(1.0*(X[i]-X[j])*(X[i]-X[j])+1.0*(Y[i]-Y[j])*(Y[i]-Y[j])),make_pair(i,j));
	sort(e+1,e+1+m);
	double l=0.0,r=200.0;
	while(l<=r-eps){
		double mid=(l+r)/2;
		if(check(mid)) l=mid+eps;
		else r=mid-eps;
	}
	printf("%.7f\n",(l-eps)/2);
	return 0;
}


 #include<bits/stdc++.h>
#define ll long long
#define fr(i,k,n) for(ll i = k;i<n;i++)
using namespace std;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

  ll a,b;
  long double w;
  cin>>a>>b>>w;
  ll c = w*1000;
  ll mini = LONG_MAX;
  ll maxi = LONG_MIN;
  for(ll i = 0;i<=1000000;i++){

      if(a*i <= c && c <= b*i){
          mini = min(mini,i);
          maxi = max(maxi,i);
      }
  }

  if(mini == LONG_MAX || maxi == LONG_MIN){
      cout<<"UNSATISFIABLE"<<"\n";
  }
else{
    cout<<mini<<" "<<maxi<<"\n";
}

}

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define code                     \
	ios::sync_with_stdio(false); \
	cin.tie(0);                  \
	cout.tie(0);
#define int long long
#define endl '\n'
#define MM(a, b) memset(a, b, sizeof(a))
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}

int32_t main()
{
	code;
	int a,b,c,d; cin>>a>>b>>c>>d;
    if(a==c && b==d) cout << 0 << endl;
    else if((a+b)==(c+d) || (a-b)==(c-d) || abs(a-c)+abs(b-d)<=3) cout << 1 << endl;
    else{
        if(((a+b)%2)==((c+d)%2)) cout << 2 << endl;
        else if(abs(a-c)+abs(b-d)<=6) cout << 2 << endl;
        else if (abs(a+b-c-d)<=3 || abs(a-b-c+d)<=3) cout << 2 << endl;
        else cout << 3 << endl;
    }
}


#include<bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define pb push_back
template <typename _Tp>void read(_Tp &x){
	char ch(getchar());bool f(false);while(!isdigit(ch))f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();while(isdigit(ch))x=x*10+(ch&15),ch=getchar();
	if(f)x=-x;
}
template <typename _Tp,typename... Args>void read(_Tp &t,Args &...args){read(t);read(args...);}
template <typename _Tp>inline void chmax(_Tp &a,const _Tp &b){a=a<b?b:a;}
template <typename _Tp>inline void chmin(_Tp &a,const _Tp &b){a=a<b?a:b;}
const int N=100005;
typedef long long ll;
std::vector<ll> a[3];
ll last[3];
ll calc(const std::vector<ll> &a,const std::vector<ll> &b){
	std::vector<std::pair<ll,int>> v;
	for(auto it:a)v.pb({it,0});
	for(auto it:b)v.pb({it,1});
	std::sort(v.begin(),v.end());
	last[0]=last[1]=-1e18;
	ll ans=1e18;
	for(auto [x,y]:v)chmin(ans,x-last[!y]),last[y]=x;
	return ans;
}
int main(){
	int n;read(n);
	for(int i=1;i<=n+n;++i){
		ll x;read(x);
		char ch;do{ch=getchar();}while(!isalpha(ch));
		a[ch=='R'?0:ch=='G'?1:2].pb(x);
	}
	if(SZ(a[0])%2==0&&SZ(a[1])%2==0&&SZ(a[2])%2==0)return puts("0"),0;
	int p=-1;for(int i=0;i<3;++i)if(SZ(a[i])%2==0)p=i;
	std::vector<ll> x,y,z=a[p];
	if(p==0)x=a[1],y=a[2];
	else if(p==1)x=a[0],y=a[2];
	else if(p==2)x=a[0],y=a[1];
	printf("%lld\n",std::min(calc(x,y),calc(x,z)+calc(y,z)));
	return 0;
}

// doot diddly donger cuckerino Hahahahahah

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

#define all(x)  (x).begin(), (x).end()
const ld PI = acos(-1);

template <typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template <typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
template <typename T, typename U>
std::ostream& operator<<(std::ostream& stream, const pair<T, U>& p) {
  return stream << p.first << " " << p.second;
}
template <typename T>
std::ostream& operator<<(std::ostream& out, const vector<T>& vec) {
  for (const T& x: vec) out << x << ' ';
  return out;
}
template <typename T>
std::istream& operator>>(std::istream& in, vector<T>& vec) {
  for (auto& x: vec) in >> x;
  return in;
}

#define sim       template<typename T
#define ris       return *this
#define dor       > debug & operator <<
#define eni(x)    sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> rang(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << rang((i).begin(), (i).end()); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

class CTricolorPyramid {
public:

  void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> a(n);
    map<char, int> mp = {
        {'B', 0},
        {'W', 1},
        {'R', 2},
    };
    vector<vector<int>> C(3, vector<int>(3, 0));
    for (int i = 0; i < 3; ++i) {
      C[i][i] = C[i][0] = 1;
    }
    for (int i = 1; i < 3; ++i) {
      for (int j = 1; j < i; ++j) {
        C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % 3;
      }
    }
    auto getC = [](int n, int k, const vector<vector<int>>& C) {
      if (k < 0 || k > n) return 0;
      int ans = 1;
      while(n > 0) {
        int x = n % 3;
        int y = k % 3;
        n /= 3;
        k /= 3;
        ans = (ans * C[x][y]) % 3;
      }
      return ans;
    };
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      int w = getC(n - 1, i, C);
      w *= mp[s[i]];
      ans = (ans + w) % 3;
    }
    for (int i = 1; i < n; i++) {
      if (ans & 1) ans += 3;
      ans /= 2;
    }
    for (auto[k, v]: mp) {
      if (v == ans) {
        cout << k << '\n';
      }
    }
  }
};

int32_t main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	CTricolorPyramid solver;

	solver.solve();
	return 0;
}


#include<bits/stdc++.h>
typedef long long int ll ;
#define rep(i,k,n) for (i = k; i < n; i++)
using namespace std;
const unsigned int M = 1000000007;
const unsigned int n=100005;
/*bool sol(pair<ll,ll>a,pair<ll,ll>b)
{
    return (b.first>a.first);

}*/
/*
int64_t ceil_div(int64_t a, int64_t b) {
    return (a + b - 1) / b;

}*/

void fun()
{
    ll n;
    char a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b==c)
    {
        cout<<"Won"<<endl;
    }
    else
    {
        cout<<"Lost"<<endl;
    }

}

int main()
{
//ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 long long int t;
t=1;

 //cin>>t;
 while(t--)
 {
    fun();

   //fflush(stdin);
 }
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

int main()
{
    fast

     string s; cin>>s;
     if(s[0]==s[1]&&s[1]==s[2])
        cout<<"Won";
     else
        cout<<"Lost";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 200003
#define MOD 998244353
#define INF 1000000000

int main(){
  ll X,Y,Z;
  cin>>X>>Y>>Z;
  for(ll i=1000000;;i--){
    //Y/X>ans/Z;
    if(Y*Z>i*X){
      cout<<i<<endl;
      return 0;
    }
  }
}

#include<bits/stdc++.h>

using namespace std;
#define int long long
// typedef long long int;

int const N = 4e6 + 10, mod = 1e9 + 7;
int fact[N], infact[N];
int n, m, k;

int qmi(int a, int k, int p) {
    int res = 1;
    while (k) {
        if (k & 1) res = res * a % p;
        k >>= 1;
        a = a * a % p;
    }
    return res;
}

// 预处理
void init() {
    fact[0] = infact[0] = 1;
    for (int i = 1; i < N; ++i) {
        fact[i] = (int)fact[i - 1] * i % mod;
        infact[i] = (int)infact[i - 1] * qmi(i, mod - 2, mod) % mod;
    }
}

int cnm(int a, int b) {
    return (int)fact[a] * infact[b] % mod * infact[a - b] % mod;
}

signed main() {
    init();  // 预处理
    cin >> n >> m >> k;  // c(n + m, n) - c(n + m, n - k - 1)
    if (n >= m + k + 1) cout << 0;  // 无解
    else cout << ((cnm(n + m, n) % mod - cnm(n + m, n - k - 1) % mod) % mod + mod) % mod ;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxl=300005,LG=55;

int n,m,q,num=0,opt,u,v;
int a[maxl],tree[maxl*LG],L[maxl*LG],R[maxl*LG];
int fa[maxl],RT[maxl];

int fin(int x)
{
	if (x==fa[x])  return x;
	return fa[x]=fin(fa[x]);
}

void pushup(int rt)
{
	tree[rt]=tree[L[rt]]+tree[R[rt]];
}

int change(int nl,int l,int r,int rt,int k)
{
	if (rt==0)  rt=++num;
	if (l==r)
	{
		tree[rt]+=k;
		return rt;
	}
	int mid=(l+r)>>1;
	if (nl<=mid)  L[rt]=change(nl,l,mid,L[rt],k);
	else R[rt]=change(nl,mid+1,r,R[rt],k);

	pushup(rt);

	return rt;
}

int query(int nl,int l,int r,int rt)
{
	if (l==r)  return tree[rt];

	int mid=(l+r)>>1;
	if (nl<=mid)  return query(nl,l,mid,L[rt]);
	else return query(nl,mid+1,r,R[rt]);
}

int merge(int x,int y,int l,int r)
{
	if (!x)  return y;if (!y)  return x;
	if (l==r)
	{
		tree[x]+=tree[y];
		return x;
	}
	int mid=(l+r)>>1;
	L[x]=merge(L[x],L[y],l,mid);
	R[x]=merge(R[x],R[y],mid+1,r);
	pushup(x);

	return x;
}

void Merge(int x,int y)
{
	RT[x]=merge(RT[x],RT[y],1,n);
	fa[y]=x;
}

signed main()
{
	cin>>n>>m;
	for (int i=1;i<=n;i++)  cin>>a[i],fa[i]=i;
	for (int i=1;i<=n;i++)  RT[i]=change(a[i],1,n,RT[i],1);

	while (m--)
	{
		cin>>opt>>u>>v;
		if (opt==1)
		{
			int fx=fin(u),fy=fin(v);
			if (fx!=fy)  Merge(fx,fy);
		}
		else
		{
			int now=fin(u);
			cout<<query(v,1,n,RT[now])<<endl;
		}
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

struct dsu {
	public:
		dsu(int n): cnt(n), par(n), siz(n, 1) {
			for (int i = 0; i < n; i++) par[i] = i;
		}
		bool merge(int x, int y) {
			x = find(x);
			y = find(y);
			if (x == y) return false;
			if (siz[x] < siz[y]) swap(x, y);
			siz[x] += siz[y];
			par[y] = x;
			--cnt;
			return true;
		}
		int find(int x) {
			return par[x] == x ? x : par[x] = find(par[x]);
		}
		int size(int x) {
			return siz[find(x)];
		}
		bool same(int x, int y) {
			return find(x) == find(y);
		}
		int groups() {
			return cnt;
		}
	private:
		int cnt;
		vector<int> par, siz;
};

int main() {
	int n, q;
	cin >> n >> q;
	dsu uf(n*2);
	map<int,int> ids;
	vector<map<int,int>> mps(n);
	rep(i,n) {
		int c;
		cin >> c;
		c--;
		ids[i] = c;
		mps[i][c]++;
	}
	rep(i,q) {
		int x, a, b;
		cin >> x >> a >> b;
		a--, b--;
		if (x == 1) {
			if (uf.same(a, b)) continue;
			if (uf.size(a) < uf.size(b)) {
				swap(a, b);
			}
			for (auto p: mps[uf.find(b)]) {
				mps[uf.find(a)][p.first] += p.second;
			}
			uf.merge(a, b);
		} else {
			cout << mps[uf.find(a)][b] << endl;
		}
	}
}


#include"bits/stdc++.h"

int main() {

	using namespace std;

	int A, B;
	cin >> A >> B;

	cout << (2 * A + 100) - B << endl;

	return 0;

}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#include <cmath> //数学関数
using ll = long long;

int main() {
  int x,y;
  cin>>x>>y;

  if(x == y) cout<<x<<endl;

  else if(x == 0) {
    if(y == 1) cout<<2<<endl;
    else cout<<1<<endl;
  }
  else if(x == 1) {
    if(y == 0) cout<<2<<endl;
    else cout<<0<<endl;
  }
  else if(x == 2) {
    if(y == 0) cout<<1<<endl;
    else cout<<0<<endl;
  }
}


#include<bits/stdc++.h>
using namespace std;
#define io cin.tie(0);ios::sync_with_stdio(false);
#define debug(x) cout<<#x<<"="<<x<<endl
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define mk make_pair
#define ll long long
#define rs p<<1|1
#define ls p<<1
const int maxn = 2005;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
inline ll read(){
    ll p=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){p=(p<<1)+(p<<3)+(c^48),c=getchar();}
    return f*p;
}

int dis1[maxn][maxn], dis2[maxn][maxn], vis[maxn];
struct node{
    int u, w;
    bool operator < (const node &a) const{
        return w > a.w;
    }
};
vector<node> v1[maxn], v2[maxn];
void dij1(int st){
    dis1[st][st] = 0;
    queue<node> q;
    q.push({st, 0});
    while(q.size()){
        node t = q.front(); q.pop();
        int from = t.u;
        for(auto it : v1[from]){
            int to = it.u, w = it.w;
            if(dis1[st][from] + w < dis1[st][to]){
                dis1[st][to] = dis1[st][from] + w;
                q.push({to, dis1[st][to]});
            }
        }
    }
}
void dij2(int st){
    dis2[st][st] = 0;
    queue<node> q;
    q.push({st, 0});
    while(q.size()){
        node t = q.front(); q.pop();
        int from = t.u;
        for(auto it : v2[from]){
            int to = it.u, w = it.w;
            if(dis2[from][st] + w < dis2[to][st]){
                dis2[to][st] = dis2[from][st] + w;
                q.push({to, dis2[to][st]});
            }
        }
    }
}
void solve(){
    int n, m;
    scanf("%d%d", &n, &m);
    fill(vis, vis + maxn, inf);
    for(int i = 1; i <= m; i ++){
        int x, y, w;
        scanf("%d%d%d", &x, &y, &w);
        if(x == y){
            vis[x] = min(vis[x], w);
            continue;
        }
        v1[x].push_back({y, w});
        v2[y].push_back({x, w});
    }
    memset(dis1, inf, sizeof dis1);
    memset(dis2, inf, sizeof dis2);
    for(int i = 1; i <= n; i ++){
        dij1(i);
        dij2(i);
    }
    for(int i = 1; i <= n; i ++){
        int ans = inf;
        for(int j = 1; j <= n; j ++){
            if(i == j) continue;
            ans = min(ans, dis1[i][j] + dis2[j][i]);
        }
        ans = min(ans, vis[i]);
        if(ans == inf) ans = -1;
        printf("%d\n", ans);
    }
}
int main(){
    solve();
    return 0;
}

#include <bits/stdc++.h>
//#include <cmath>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
//#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define bs(yup,x) binary_search(yup.begin(),yup.end(),x) //it will return bollean value
#define lb(yup,x) lower_bound(yup.begin(),yup.end(),x)  //it will return the adress of the number which is equal to or just greater than x ,and if it is equal to yup.end() than their in no such number exist
#define ub(yup,x) upper_bound(yup.begin(),yup.end(),x)
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
using namespace std;
const long long N=200005, INF=2000000000000000000;
const long double EPS= 0.000000000001;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
vi prime;
bool isprime[N];
void pre()
{
    for(int i=2;i<N;i++)
    {
        if(isprime[i])
        {
            for(int j=i*i;j<N;j+=i)
            isprime[j]=false;
            prime.pb(i);
        }
    }
    return;
}

int32_t main()
{

    IOS;
    //fill(isprime, true);
    //pre();
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n,m,q;
        cin>>n>>m>>q;
        pair<int ,int> a[n];
        rep(i,0,n) cin>>a[i].ss>>a[i].ff;
        sort(a,a+n,greater< pii >());
        int b[m+1];
        rep(i,1,m+1) cin>>b[i];
        while(q--)
        {
            int l,r,ans=0;
            cin>>l>>r;
            set<int>s;
            vi v;
            rep(i,1,l) v.pb(b[i]);
            rep(i,r+1,m+1) v.pb(b[i]);
            sort(all(v));
            for(int i=0;i<n;i++)
            {
                auto pos=lower_bound(all(v),a[i].ss);
                if(pos!=v.end())
                {
                    ans+=a[i].ff;
                    v.erase(pos);
                }
            }
            cout<<ans<<"\n";
        }
    }

}


#include<bits/stdc++.h>
#define maxn 250000
using namespace std;
int n;
char s[maxn];
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	if(s[1]!=s[n])
		cout<<1<<endl;
	else
	{
		int ok=1;
		for(int i=1;i<n;i++)
			if(s[i]!=s[1]&&s[i+1]!=s[n])
				ok=0;
		if(ok==0)
			cout<<2<<endl;
		else
			cout<<-1<<endl;
	}

	return 0;
}

#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <map>

#define fore(i, l, r) for(int i = int(l); i < int(r); i++) //Python style baby
#define sz(a) int((a).size())
#define mp make_pair
#define vi vector<int>
#define vpi vector<pair<int, int>>
#define vl vector<long long>
#define vpl vector<pair<long long, long long>>

using namespace std;
using ll = long long;
int mode, t;

void solve() {
  string s;
  cin >> s;
  reverse(s.begin(), s.end());

  map<char, char> d;
  d['6'] = '9';
  d['9'] = '6';
  d['0'] = '0';
  d['8'] = '8';
  d['1'] = '1';
  for (char c : s) {
    cout << d[c];
  }
  cout << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);

  mode = 0;
  if (mode == 0) {
    solve();
  } else {
    cin >> t;
    while (t--) {
      solve();
    }
  }
}


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

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}

const int N=200005;

int n,k;
vector<int> e[N];

int vis[N],q[N],hi=1,ti,mid,up[N][20];

int get_k(int u) {
	for(int i=0;i<=19;i++) if(mid&(1<<i)) u=up[u][i];
	return u;
}

void dfs(int u,int x) {
//	if(u==12) cout<<x<<endl;
//	cout<<u<<' '<<x<<endl;
	if(x==mid+1 || (vis[u]<=x+1 && vis[u]!=0)) return;
	vis[u]=x+1;
	for(int i=0;i<e[u].size();i++) {
		dfs(e[u][i],x+1);
	}
}

void get_fa(int u,int fa) {
	up[u][0]=fa;
	for(int i=1;i<=19;i++) up[u][i]=up[up[u][i-1]][i-1];
	for(int i=0;i<e[u].size();i++) {
		if(e[u][i]!=fa) get_fa(e[u][i],u);
	}
}

bool check() {
	int ans=0;
	memset(vis,0,sizeof(vis));
	for(int i=n;i>=1;i--) {
		if(vis[q[i]]) continue;
		ans++;
//		cout<<"g"<<get_k(q[i])<<endl;
//		cout<<vis[]

		dfs(get_k(q[i]),0);
//		for(int j=1;j<=n;j++) cout<<vis[]
//		exit(0);
	}
	if(ans<=k) return 1;
	else return 0;
}

signed main() {
	n=read(),k=read();
	for(int i=1,u,v;i<n;i++) {
		u=read(),v=read();
		e[u].push_back(v),e[v].push_back(u);
	}
	//求出每个点的距离
	get_fa(1,1);
	q[++ti]=1; vis[1]=1;
	while(hi<=ti) {
		int u=q[hi++];
		for(int i=0;i<e[u].size();i++) {
			if(!vis[e[u][i]]) q[++ti]=e[u][i],vis[e[u][i]]=1;
		}
	}
//	mid=1;
//	cout<<check()<<endl;
	int l=0,r=2e5;
	while(l<r) {
		mid=(l+r)>>1;
		if(check()) r=mid;
		else l=mid+1;
	}
	cout<<l<<endl;

}

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

#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;++i)
#define per(i,a,b) for(int i=(a),i##end=(b);i>=i##end;--i)
//mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
template<typename T>void chkmax(T&x,T y){if(x<y)x=y;}
template<typename T>void chkmin(T&x,T y){if(x>y)x=y;}
inline int read(){
  #define nc getchar()
  int x=0;char c=nc;bool f=0;
  while(c<48)f|=c=='-',c=nc;
  while(c>47)x=x*10+(c^48),c=nc;
  return f?-x:x;
  #undef nc
}

typedef double db;
typedef long long ll;
typedef vector<int>vi;
typedef pair<int,int>pii;
const int maxn=2e5+10;
int n,k;vi E[maxn];

int mid;
int res,F[maxn],G[maxn];

void dfs(int u,int f){
  F[u]=1e9,G[u]=-1;
  for(int v:E[u])if(v!=f){
    dfs(v,u);
    chkmin(F[u],F[v]+1);
  }
  for(int v:E[u])if(v!=f){
    if(G[v]+F[u]>=mid){
      chkmax(G[u],G[v]+1);
    }
  }
  if(F[u]>mid)chkmax(G[u],0);
  if(G[u]==mid){
    res++,F[u]=0,G[u]=-1;
  }
}

void solve(){
  cin>>n>>k;
  rep(i,2,n){
    int u=read(),v=read();E[u].push_back(v),E[v].push_back(u);
  }
  int l=1,r=n;
  while(l<r){
    mid=(l+r)/2,res=0,dfs(1,0);
    if(G[1]!=-1)res++;
    res<=k?r=mid:l=mid+1;
  }
  cout<<l<<endl;
}

signed main(){
//  int T=read();
//  while(T--)solve();
  solve();
  return 0;
 }