#include <bits/stdc++.h>
const double PI(acos(-1.0));
const double PI_2 = PI * 2.0;
double eps = 1e-9;
using namespace std;
int main() {
  string s;
  cin >> s;
  string ans = s;
  long long p = 0, k = 0;
  for (long long(i) = (0); i <= (((long long)((long long)s.size())) - 1); ++(i))
    p += s[i] - '0';
  for (long long(i) = (0); i <= (((long long)((long long)s.size())) - 1);
       ++(i)) {
    if (s[i] != '0') {
      string temp = s;
      temp[i]--;
      for (long long(j) = (i + 1); j <= (((long long)s.size()) - 1); ++(j)) {
        temp[j] = '9';
      }
      long long tp = 0;
      for (long long(i) = (0); i <= (((long long)((long long)s.size())) - 1);
           ++(i))
        tp += temp[i] - '0';
      if (p < tp || p == tp && ans < temp) {
        ans = temp;
        p = tp;
      }
    }
  }
  for (long long(i) = (0); i <= (((long long)((long long)ans.size())) - 1);
       ++(i)) {
    if (ans[i] != '0') {
      cout << ans.substr(i) << endl;
      return 0;
    }
  }
  return 0;
}
