#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
const long double EPS = 1.0E-14;
vector<pair<long long, string> > vec;
bool comp(const pair<long long, string> &A, const pair<long long, string> &B) {
  if (A.first == B.first) {
    for (int i = 0; i < A.second.size(); i++) {
      if (A.second[i] == B.second[i])
        continue;
      else
        return A.second[i] > B.second[i];
    }
  } else
    return A.first > B.first;
}
int main() {
  long long sum = 0;
  string s;
  cin >> s;
  if (s.size() == 1)
    cout << s;
  else {
    for (int i = 0; i < s.size(); i++) {
      sum += s[i] - '0';
    }
    vec.push_back({sum, s});
    for (int i = s.size() - 1; i >= 1; i--) {
      s[i] = '9';
      while (s[i - 1] == '0') {
        s[i - 1] = '9';
        i--;
      }
      s[i - 1]--;
      sum = 0;
      for (int j = 0; j < s.size(); j++) {
        sum += s[j] - '0';
      }
      vec.push_back({sum, s});
    }
    sort(vec.begin(), vec.end(), comp);
    if (vec[0].second[0] == '0') {
      for (int i = 1; i < vec[0].second.size(); i++) cout << vec[0].second[i];
    } else {
      cout << vec[0].second;
    }
  }
  return 0;
}
