#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    s64 s, p;
    cin >> s >> p;

    string ans = "No";
    for (s64 n = 1; n * n <= p; ++n)
    {
        if (p % n == 0)
        {
            s64 m = p / n;
            if (n + m == s) ans = "Yes";
        }
    }

    cout << ans << "\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back               
#define mp make_pair         
#define nline "\n"
const ll M1=1e9+7;                                               
const ll M=998244353;                    
const ll N=100005;   
const ll INF_ADD=1e18;
const ll INF_MUL=1e13;                                    
#define f first                          
#define s second                             
#define pll pair<ll,ll>   
#ifndef ONLINE_JUDGE 
#define debug(x) cerr<<#x<<" "; _print(x); cerr<<nline;
#else
#define debug(x);
#endif  
void _print(ll x){cerr<<x;}    
template<class T,class V> void _print(pair<T,V> p) {cerr<<"{"; _print(p.first);cerr<<","; _print(p.second);cerr<<"}";}
template<class T>void _print(vector<T> v) {cerr<<" [ "; for (T i:v){_print(i);cerr<<" ";}cerr<<"]";}
template<class T>void _print(set<T> v) {cerr<<" [ "; for (T i:v){_print(i); cerr<<" ";}cerr<<"]";}
template<class T>void _print(multiset<T> v) {cerr<< " [ "; for (T i:v){_print(i);cerr<<" ";}cerr<<"]";}
template<class T,class V>void _print(map<T, V> v) {cerr<<" [ "; for(auto i:v) {_print(i);cerr<<" ";} cerr<<"]";} 
//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ll optimal(ll x,ll t){
    ll sq=sqrt(x);
    set<ll> comp;
    comp.insert(t+x/(t+1));
    if(sq>t)   
        comp.insert(sq+x/(sq+1));
    sq++;    
    if(sq>t)  
        comp.insert(sq+x/(sq+1));
    sq++;
    if(sq>t)
        comp.insert(sq+x/(sq+1));
    sq=sqrt(x);
    sq--;
    if(sq>t)
        comp.insert(sq+x/(sq+1));
    sq--;
    if(sq>t)
        comp.insert(sq+x/(sq+1));
    ll best=*(comp.begin());
    return best;
}
void solve(){   
    ll n,m; cin>>n>>m;
    vector<vector<pll>> adj(n+2);
    vector<ll> ans(n+5,INF_ADD);
    priority_queue<pll> prefer;
    prefer.push({0,1});
    vector<vector<ll>> a(m+4,vector<ll>(5,0));
    ans[1]=0;
    for(ll i=1;i<=m;i++){
        for(ll j=1;j<=4;j++)
            cin>>a[i][j];
        adj[a[i][1]].pb({a[i][2],i});
        adj[a[i][2]].pb({a[i][1],i}); 
    }
    while(prefer.size()){
        auto it=prefer.top();
        prefer.pop();
        if(ans[it.s]!=-it.f)
            continue;
        ll node=it.s,instant=-it.f;
        for(auto chld:adj[node]){
            ll compare=(a[chld.s][3]+optimal(a[chld.s][4],instant));
            if(compare<ans[chld.f]){
                prefer.push({-compare,chld.f});
                ans[chld.f]=compare;
            }
        }
    }
    if(ans[n]!=INF_ADD)
        cout<<ans[n];
    else
        cout<<"-1";

}             
int main()                                             
{         
    ios_base::sync_with_stdio(false);                        
    cin.tie(NULL);                     
    #ifndef ONLINE_JUDGE          
    freopen("input.txt", "r", stdin);                                         
    freopen("output.txt", "w", stdout);  
    freopen("error.txt", "w", stderr);                        
    #endif    
    ll t=1;           
    //cin>>t;
    while(t--){
        solve();
    }
    /*
    Correct data type?
    Infinity?
    Base case?
    */
    cerr<<"Time:"<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n"; 
} 