#include <bits/stdc++.h>
using namespace std;
long long sums, sumt, ch, n, k, a, sum;
string s, t, ss;
bool f, flag;
int main() {
  cin >> s;
  n = s.size();
  sumt = s[0] - 48 - 1;
  ch = sumt;
  sum += s[0] - 48;
  for (int i = 1; i < n; i++) {
    if (s[i] == '9') f = true;
    t += 57;
    sumt += 9;
    sum += s[i] - 48;
  }
  if (f == true) {
    for (int i = 0; i < s.size() - 1; i++) {
      if (s[i] == '9' && k == 0 && s[i + 1] != '9') {
        ss += '8';
        flag = true;
        k = 1;
      } else if (flag == false)
        ss += s[i];
      else if (flag == true)
        ss += '9';
    }
    ss += '9';
  } else
    ss = s;
  for (int i = 0; i < ss.size(); i++) {
    sums = sums + ss[i] - 48;
  }
  if (n == 1) {
    cout << ss[0];
    return 0;
  }
  if (sum >= sums && sum >= sumt)
    cout << s;
  else if (sums >= sumt)
    cout << ss;
  else {
    if (ch != 0) cout << ch;
    cout << t;
  }
}
