#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long
#define mod 1000000007

using namespace std;

//---------------------約数の列挙
vector<long long int> divisor(long long int N){
	vector<long long int> p;
	for(long long int q=1;q*q<=N;q++){
		if(N%q == 0){
			p.push_back(q);
			if(N/q != q){
				p.push_back(N/q);
			}
			else{}
		}
		else{}
	}
	sort(p.begin(),p.end());
	return p;
}

int main(){

ll int S,P;
cin >> S >> P;
	if(1+P==S){
		cout << "Yes";
		return 0;
	}
vector<ll int > a;

a = divisor(P);
ll int i=0;
ll int j=0;
ll int N ;
N = a.size();
while(i < sqrt(P) || j!=N){

	i=a[j];
	if(i + (P/i) == S){
		cout << "Yes";
		return 0;
	}
	else{}
	j+=1;
}


		cout << "No";










	return 0;

}


/*
{
######################
#       Author       #
#        Gary        #
#        2021        #
######################
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
//inline int read(){
//    int x=0;
//    char ch=getchar();
//    while(ch<'0'||ch>'9'){
//        ch=getchar();
//    }
//    while(ch>='0'&&ch<='9'){
//        x=(x<<1)+(x<<3)+(ch^48);
//        ch=getchar();
//    }
//    return x;
//}
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
const int MAXN=2e5+233;
int k,n;
vector<int> g[MAXN];
struct inf{
	int cnt,dis,ty;
	inf(){cnt=dis=ty=0;}
	inf(int A,int B,int C){cnt=A,dis=B,ty=C;}
};
int D;
inf operator + (inf A,inf B){
	if(A.ty&&B.ty) return inf(A.cnt+B.cnt,max(A.dis,B.dis),1);
	if(!A.ty&&!B.ty) return inf(A.cnt+B.cnt,min(A.dis,B.dis),0);
	if(A.ty>B.ty) swap(A,B);
	if(A.dis+B.dis<=D) return inf(A.cnt+B.cnt,A.dis,0);
	return inf(A.cnt+B.cnt,B.dis,1); 
}
inf get(int now,int fa){
	inf ret;
	if(g[now].size()==1&&fa){
		return inf(0,0,1);
	}
	bool ok=0;
	for(auto it:g[now]){
		if(it!=fa){
			auto Tmp=get(it,now);
			Tmp.dis++;
			if(!ok) ret=Tmp;
			else ret=ret+Tmp;
			ok=1;
		}
	}
	if(II(ret.dis,ret.ty)==II(D,1)){
		ret=inf(ret.cnt+1,0,0);
	}
	if(II(ret.dis,ret.ty)==II(D+1,0)){
		ret=inf(ret.cnt,0,1);
	}
//	cout<<now<<" "<<ret.cnt<<' '<<ret.dis<<' '<<ret.ty<<endl;
	return ret;
}
bool check(int d){
	D=d;
	auto it=get(1,0);
	return it.cnt+it.ty<=k;
}
int main(){
	scanf("%d%d",&n,&k);
	rb(i,1,n-1){
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].PB(v);
		g[v].PB(u);
	}
	int l=1,r=n;
	while(l<r){
		int mid=(l+r)>>1;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	cout<<l<<endl;
	return 0;
}