#include <bits/stdc++.h>
using namespace std;
long long n, m, a[20];
void input() { cin >> m; }
void output() {}
bool check() {
  long long dt = 0, dc = 0;
  for (long long i = 1; i <= n - 1; i++) {
    if (a[i] == 9)
      dc++;
    else if (a[i] == 8)
      dt++;
  }
  if ((dt == 1 && dc == n - 2) || dc == n - 1) return 1;
  return 0;
}
void solve() {
  while (m > 0) {
    n++;
    a[n] = m % 10;
    m /= 10;
  }
  if (check()) {
    for (long long i = n; i >= 1; i--) cout << a[i];
  } else {
    if (a[n - 1] == 9) {
      cout << a[n];
      long long i = n - 1;
      while (a[i] == 9) {
        i--;
      }
      i++;
      for (long long j = n - 1; j > i; j--) {
        cout << "9";
      }
      cout << "8";
      for (long long j = i - 1; j >= 1; j--) {
        cout << "9";
      }
    } else {
      if (a[n] > 1) cout << a[n] - 1;
      for (long long i = 1; i <= n - 1; i++) cout << "9";
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  input();
  solve();
  output();
}
