#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k = -1, i, j, s1 = 0;
  string s, t;
  cin >> s;
  t = s;
  j = 0;
  for (i = s.size() - 1; i > 0; i--) {
    if (s[i] < '9') {
      j += abs('9' - s[i]);
      s[i] = '9';
    } else if (s[i] == '9' && j > 1) {
      k = i;
      s1 += j;
      j = 0;
    }
  }
  if (j > 1 || (j == 1 && k != -1)) {
    s[0]--;
    for (i = 0; i < s.size(); i++) {
      if (i == 0 && s[i] == '0') continue;
      cout << s[i];
    }
    return 0;
  }
  if (k != -1) {
    s[k]--;
    t = s;
  }
  cout << t;
  return 0;
}
