#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int i, n, k9 = 0, k8 = 0;
  cin >> s;
  for (i = 1; i < s.size(); i++) {
    k9 += (s[i] == '9');
    k8 += (s[i] == '8');
  }
  if ((k9 == s.size() - 1) || (k9 == s.size() - 2 && k8 == 1))
    cout << s << endl;
  else if (s[1] != '9') {
    s[0] = s[0] - 1;
    if (s[0] != '0') cout << s[0];
    for (i = 1; i < s.size(); i++) cout << 9;
  } else {
    int k;
    for (i = 1; i < s.size(); i++)
      if (s[i] != '9') {
        s[i - 1] = s[i - 1] - 1;
        k = i - 1;
        break;
      }
    for (i = 0; i <= k; i++) cout << s[i];
    for (i = k + 1; i < s.size(); i++) cout << "9";
  }
  return 0;
}
