#include <bits/stdc++.h>
using namespace std;
int sum(const string &s) {
  int sum = 0;
  for (int i = 0; i < s.size(); i++) {
    sum += s[i] - '0';
  }
  return sum;
}
int main(void) {
  string a;
  cin >> a;
  string b = a;
  if (a.size() == 1) {
    cout << (a[0] - '0');
    return 0;
  }
  bool need_optimisation = false;
  for (int i = 1; i < a.size(); i++) {
    if (a[i] != '9') {
      need_optimisation = true;
    }
  }
  if (need_optimisation == false) {
    cout << a;
    return 0;
  }
  for (int i = a.size() - 1; i > 0; i--) {
    need_optimisation = false;
    for (int j = 1; j < i; j++) {
      if (a[j] != '9') {
        need_optimisation = true;
        break;
      }
    }
    if (need_optimisation == false && a[i] < '8') {
      need_optimisation = true;
    }
    if (need_optimisation == false) {
      break;
    }
    if (a[i] != '9') {
      if (a[i - 1] == '0') {
        int k = 1;
        while (a[i - k] == '0') {
          a[i - k] = '9';
          k++;
        }
        a[i - k]--;
      } else {
        a[i - 1]--;
      }
      for (int j = i; j < a.size(); j++) {
        a[j] = '9';
      }
    }
  }
  if (sum(a) > sum(b)) {
    if (a[0] != '0') {
      cout << a[0];
    }
    for (int i = 1; i < a.size(); i++) {
      cout << a[i];
    }
  } else {
    cout << b;
  }
  return 0;
}
