#include <bits/stdc++.h>
using namespace std;
int get_num(string s) {
  int sum = 0;
  for (int i = 0; i < s.size(); ++i) {
    sum += s[i] - '0';
  }
  return sum;
}
int main() {
  string s, t, r;
  int ans;
  cin >> s;
  ans = get_num(s);
  r = s;
  for (int i = s.size() - 2; i >= 0; --i) {
    t = s;
    if (t[i] != 0) {
      t[i] = t[i] - 1;
      for (int j = i + 1; j < t.size(); ++j) {
        t[j] = '9';
      }
      if (t[0] == '0') {
        t.erase(0, 1);
      }
      int x = get_num(t);
      if (x > ans) {
        ans = x;
        r = t;
      }
    }
  }
  cout << r;
  return 0;
}
