#include <bits/stdc++.h>
using namespace std;
int main() {
  long long m, n, i, j, k;
  string s, ans, s1, s2;
  cin >> s;
  long long sz = s.size();
  long long sm = 0, cnt = 0, sum = 0;
  for (long long i = 0; i < sz; i++) sum += s[i] - '0';
  for (i = sz - 1; i >= 0; i--) {
    sm = sum;
    if (s[i] != 0) {
      sm--;
      for (j = i + 1; j < sz; j++) {
        sm += 9 - (s[j] - '0');
      }
    }
    if (sm > sum) {
      s[i]--;
      for (j = i + 1; j < sz; j++) s[j] = '9';
      sum = sm;
    }
  }
  if (s[0] == '0')
    for (j = 1; j < sz; j++) cout << s[j];
  else
    for (long long i = 0; i < sz; i++) cout << s[i];
}
