#include <bits/stdc++.h>
using namespace std;
signed main() {
  string s;
  cin >> s;
  long long n = s.size();
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    sum += s[i] - '0';
  }
  string a = s;
  for (long long i = n - 2; i >= 0; i--) {
    if (s[i] != '0') {
      string p = s;
      p[i] = p[i] - 1;
      for (long long j = i + 1; j < n; j++) {
        p[j] = '9';
      }
      long long su = 0;
      for (long long i = 0; i < n; i++) {
        su += p[i] - '0';
      }
      if (su > sum) {
        sum = su;
        a = p;
      }
    }
  }
  long long f = 0;
  for (long long i = 0; i < a.size(); i++) {
    if (a[i] != '0') {
      f = 1;
      cout << a[i];
    }
    if (a[i] == '0' && f == 1) {
      cout << a[i];
    }
  }
}
