#include <bits/stdc++.h>
using namespace std;
int sumd(string s) {
  int k = 0;
  for (auto i : s) k += i - '0';
  return k;
}
string strip(string s) {
  int beg;
  for (beg = 0; beg < s.size(); beg++)
    if (s[beg] != '0') break;
  return string(s.begin() + beg, s.end());
}
int main() {
  string s;
  cin >> s;
  string r = s;
  bool done = false;
  for (int i = 1; i < s.size(); i++) {
    if (done) {
      s[i] = '9';
      continue;
    }
    if (s[i] == '9') continue;
    s[i - 1]--;
    s[i] = '9';
    done = true;
  }
  if (sumd(r) >= sumd(s))
    cout << strip(r);
  else
    cout << strip(s);
}
