#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const long long INF = (long long)1 << 60;
int main() {
  string n;
  cin >> n;
  int len = n.length(), sum = 0, mx;
  string res = n;
  for (int i = 0; i < len; ++i) sum += n[i] - '0';
  mx = sum;
  for (int i = len - 2; i >= 0; --i) {
    sum -= n[i + 1] - '0';
    if (n[i] == '0') continue;
    if (sum - 1 + 9 * (len - 1 - i) > mx) {
      res[i] = n[i] - 1;
      for (int j = i + 1; j < len; ++j) res[j] = '9';
      mx = sum - 1 + 9 * (len - 1 - i);
    }
  }
  if (res[0] == '0') res.erase(0, 1);
  cout << res << "\n";
}
