#include <bits/stdc++.h>
using namespace std;
int dig_sum(const string& s) {
  int sum = 0;
  for (int k = 0; k < s.length(); k++) sum += (s[k] - '0');
  return sum;
}
int main() {
  string X;
  cin >> X;
  int n = X.length(), max_sum = dig_sum(X);
  string Max = X;
  for (int i = n - 1; i > 0; i--) {
    if (X[i] < '9') {
      X[i] = '9';
      X[i - 1]--;
    }
    if (X[i - 1] != '0' - 1) {
      if (dig_sum(X) > max_sum) {
        Max = X;
        max_sum = dig_sum(X);
      } else if (dig_sum(X) == max_sum and
                 (X > Max or X.length() > Max.length()))
        Max = X;
    }
  }
  cout << (Max[0] == '0' ? Max.substr(1, n - 1) : Max) << endl;
  return 0;
}
