#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

// constexpr ll MOD=1000000007ll;
constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  ll s, p;
  cin>>s>>p;
  for(ll n=1; n<=1000000; ++n){
    ll m=s-n;
    if(m<=0){
      continue;
    }
    if(n*m==p){
      cout<<"Yes"<<'\n';
      return 0;
    }
  }
  cout<<"No"<<'\n';
  return 0;
}

#include <bits/stdc++.h>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define L(n) (n << 1)
#define R(n) (n << 1 | 1)
#define print_vector(n) for(auto a0 : n) cout << a0 << ' '; cout << endl;
#define vector_sort(n) sort(n.begin(), n.end())
#define print_array(n, l, r) for(int a0 = l; a0 <= r; a0++) cout << n[a0] << ' '; cout << '\n';
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define ABS(a) ((a) > 0 ? (a) : -(a))
using namespace std;

template<class T>
istream & operator >> (istream &in, pair<T, T> &p) {
  in >> p.first >> p.second;
  return in;
}

template<class T>
ostream & operator <<(ostream &out, pair<T, T> &p) {
  out << p.first << ' ' << p.second;
  return out;
}

template<class Tuple, std::size_t N>
struct TuplePrinter {
  static void print(ostream &out, const Tuple& t) {
    TuplePrinter<Tuple, N-1>::print(out, t);
    out << ' ' << get<N-1>(t);
  }
};

template<class Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(ostream &out, const Tuple& t) {
    out << get<0>(t);
  }
};

template<class... Args>
ostream & operator <<(ostream &out, const tuple<Args...> &p) {
  TuplePrinter<decltype(p), sizeof...(Args)>::print(out, p);
  return out;
}

long long ans = 1e18, N, b = 1;

int main() {
  ios_base::sync_with_stdio(0);
  cin >> N;
  int cnt = 0;
  while (b <= N && b < 2e18) {
    ans = min(ans, N / b + N % b + cnt);
    b *= 2;
    cnt++;
  }
  cout << ans << "\n";
}