#include <bits/stdc++.h>
using namespace std;
string s, t, ss;
int main() {
  cin >> ss;
  s = ss;
  int n = 0;
  for (int i = 0; i < s.size(); i++) n += s[i] - '0';
  for (int i = 0; i < s.size(); i++) {
    if (ss[i] == '0') continue;
    t = ss;
    t[i]--;
    for (int j = i + 1; j < t.size(); j++) t[j] = '9';
    int m = 0;
    for (int j = 0; j < t.size(); j++) m += t[j] - '0';
    if (m > n) {
      n = m;
      s = t;
    } else if (m == n && t > s)
      s = t;
  }
  while (s[0] == '0') s.erase(0, 1);
  cout << s << "\n";
  return 0;
}
