#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, sum = 0, max = 0, ans;
  cin >> n;
  ans = n;
  vector<long long int> v;
  while (n) {
    max += (n % 10);
    v.push_back(n % 10);
    n = n / 10;
  }
  reverse(v.begin(), v.end());
  sum = v[0] - 1 + (9 * (v.size() - 1));
  if (sum > max) {
    max = sum;
    ans = 0;
    ans += v[0] - 1;
    for (long long int i = 1; i < v.size(); i++) ans = (ans * 10) + 9;
  }
  if (v.size() > 1) {
    for (long long int i = 1; i < v.size(); i++) {
      n = v[0];
      for (long long int j = 1; j < i; j++) n = (n * 10) + 9;
      if (v[i] > 8) {
        n = (n * 10) + 8;
        for (long long int j = i + 1; j < v.size(); j++) n = (n * 10) + 9;
      } else {
        if (v[i] == 8) {
          n = (n * 10) + 8;
          for (long long int j = i + 1; j < v.size(); j++) n = (n * 10) + 9;
        }
        break;
      }
      if (n > ans) ans = n;
    }
  }
  cout << ans;
  return 0;
}
