#include <bits/stdc++.h>
using namespace std;
struct Init {
  Init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.precision(20);
    cout << fixed;
  }
} init;
template <typename _Ty>
ostream& operator<<(ostream& ostr, const vector<_Ty>& v) {
  for (int i = 0; i < (int)v.size(); i++) {
    ostr << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return ostr;
}
template <typename _K, typename _V>
ostream& operator<<(ostream& ostr, const map<_K, _V>& v) {
  ostr << "{";
  for (auto iter = v.begin(); iter != v.end(); ++iter) {
    ostr << (*iter).first << ": " << (*iter).second << ", ";
  }
  ostr << "}";
  return ostr;
}
template <typename _K>
ostream& operator<<(ostream& ostr, const set<_K>& v) {
  for (auto iter = v.begin(); iter != v.end(); ++iter) {
    ostr << *iter << (iter != v.end() ? " " : "");
  }
  return ostr;
}
template <typename _K, typename _V>
ostream& operator<<(ostream& ostr, const pair<_K, _V>& v) {
  ostr << v.first << " " << v.second;
  return ostr;
}
int nCr(int n, int r) {
  int result = 1;
  for (int i = 0; i < r; i++) {
    result *= (n - i);
  }
  for (int i = 0; i < r; i++) {
    result = result / (i + 1);
  }
  return result;
}
int main() {
  string S;
  cin >> S;
  int K;
  cin >> K;
  if (K == 1) {
    int t = S.size() - 1;
    int ans = S[0] - '0';
    for (int i = 0; i < t; i++) ans += 9;
    cout << ans << endl;
    exit(0);
  }
}
