#include <iostream>

using namespace std;

int main()
{
int x,y;
cin>>x>>y;
int z=min(x,y);
int g=max(x,y);
if(z+3>g)
    cout<<"Yes";
else
    cout<<" No";

    return 0;
}


// include
#include <algorithm>
#include <complex>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

//型短縮
#define ll long long

//マクロ定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll N, K;
  cin >> N >> K;
  ll res = 0;
  string bigstr = to_string(N);
  string smallstr = to_string(N);
  if (K == 0)
    cout << N;
  else {
    rep(i, K) {
      sort(smallstr.begin(), smallstr.end());
      sort(bigstr.begin(), bigstr.end(), greater<int>());
      ll big = stoll(bigstr);
      ll small = stoll(smallstr);
      if (big - small == res) break;
      res = big - small;
      bigstr = to_string(res);
      smallstr = to_string(res);
    }
    cout << res;
  }
  return 0;
}