#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0), ios_base ::sync_with_stdio(0);
  string s;
  cin >> s;
  if (s.size() < 2) {
    cout << s;
    return 0;
  }
  string s1;
  if (s[0] > '1') s1 += char(s[0] - 1);
  long long sum1 = s[0] - '0';
  long long sum2 = sum1 - 1;
  for (int i = 1; s[i]; ++i) {
    s1 += '9';
    sum2 += 9;
    sum1 += (s[i] - '0');
  }
  if (sum1 >= sum2)
    cout << s;
  else {
    string s3;
    s3 += s[0];
    int i = 1;
    long long pos = 0;
    for (; s[i]; ++i) {
      if (s[i] == '9') {
        pos = i;
      } else
        break;
    }
    if (!pos)
      cout << s1;
    else {
      for (int i = 1; s[i]; ++i) {
        if (i < pos || i > pos)
          s3 += '9';
        else
          s3 += '8';
      }
      cout << s3;
    }
  }
}
