#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, tst;
  int n = 0, m = 0;
  cin >> s;
  if (s.size() == 1) {
    cout << s;
    return 0;
  }
  int zeros = count(s.begin(), s.end(), '0');
  int nin = count(s.begin(), s.end(), '9');
  int ons = count(s.begin(), s.end(), '1');
  if (nin == s.size() || nin == s.size() - 1 && s[0] != '9') {
    cout << s;
    return 0;
  }
  if (zeros == s.size() - 1) {
    if (s[0] == '1')
      cout << string(zeros, '9');
    else
      cout << (s[0] - '0') - 1 << string(zeros, '9');
    return 0;
  }
  if (ons == s.size() || ons + zeros == s.size()) {
    cout << string(s.size() - 1, '9');
    return 0;
  }
  for (int i = 0; i < s.size(); i++) n += s[i] - '0';
  int mx = -1;
  string ans = "";
  for (int i = 0; i < s.size(); i++) {
    for (int k = 0; k < i; k++) {
      tst += s[k];
      m += s[k] - '0';
    }
    {
      for (int j = i; j < s.size(); j++) {
        if (i == j && s[j] == '0') break;
        if (j == i && s[j] == '1') {
          continue;
        }
        if (s[j] == '1') {
          m += 9, tst += '9';
          continue;
        }
        if (i == j && s[j]) {
          m += s[j] - '0' - 1;
          stringstream ss;
          ss << s[j] - '0' - 1;
          tst += ss.str();
        } else {
          tst += '9';
          m += 9;
        }
      }
      if (m > mx)
        mx = m, ans = tst;
      else if (m == mx && ans != s)
        ans = tst, mx = m;
      if (n == mx) ans = s;
      tst = "", m = 0, n = 0;
    }
  }
  if (n >= mx)
    cout << s;
  else
    cout << ans;
}
