#include <bits/stdc++.h>
using namespace std;
int main() {
  string n, a;
  cin >> n;
  a = n;
  for (int i = 1; i < a.size(); ++i) a[i] = '9';
  if (a <= n) {
    cout << a << endl;
    return 0;
  }
  for (int i = a.size() - 1; i >= 0; --i) {
    a[i] = a[i] - 1;
    if (a <= n) {
      if (a[0] == '0')
        for (int i = 1; i < a.size(); ++i) cout << a[i];
      else
        cout << a;
      return 0;
    }
    a[i] = a[i] + 1;
  }
  cout << n << endl;
  return 0;
}
