#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, maxs, nows = "", str, l = "";
  int maxl = 0, i = 0, sl = 0, sq;
  cin >> s;
  for (int i = 0; i < s.size() - 1; i++) {
    nows += "9";
    maxl += 9;
    if (i > 0) {
      l += "9";
    }
  }
  for (int i = 0; i < s.size(); i++) {
    sl += s[i] - 48;
  }
  while (char((i + 1) + '0') + nows <= s) {
    i++;
  }
  maxl += i;
  if (i != 0) {
    maxs = char(i + '0') + nows;
  } else {
    maxs = nows;
  }
  sq = (s.size() - 2) * 9 + s[0] - 40;
  if (sq >= maxl) {
    for (int i = 0; i < s.size() - 1; i++) {
      str = l;
      str.insert(i, "8");
      if ((maxs.size() < 1 + str.size() || s[0] + str > maxs) &&
          s[0] + str <= s) {
        maxs = s[0] + str;
        maxl = sq;
      }
    }
  }
  if (maxl > sl) {
    cout << maxs;
  } else {
    cout << s;
  }
  return 0;
}
