#include <bits/stdc++.h>
using namespace std;
bool check_nines(string& s) {
  for (int i = 1; i < s.size(); ++i)
    if (s[i] != '9') return false;
  return true;
}
bool check_eight(string& s) {
  int i = 1;
  for (; i < s.size(); ++i)
    if (s[i] != '9') {
      if (s[i] == '8') {
        for (++i; i < s.size(); ++i)
          if (s[i] != '9') return false;
        return true;
      } else
        return false;
    }
  return false;
}
int check_nine(string& s) {
  for (int i = 1; i < s.size(); ++i) {
    if (s[i] == '9') continue;
    return i - 1;
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  string s;
  while (cin >> s) {
    if (check_nines(s) || check_eight(s))
      cout << s;
    else {
      int lastNine = check_nine(s);
      for (int i = 0; i < lastNine; ++i) cout << s[i];
      if (s[lastNine] - 1 > '0') cout << (char)(s[lastNine] - 1);
      for (int i = lastNine + 1; i < s.size(); ++i) cout << '9';
    }
    cout << endl;
  }
}
