#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int maxsum = 0;
  cin >> s;
  int n = s.length();
  for (int i = 0; i < n; i++) maxsum += s[i] - '0';
  string ans = s;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == '0') continue;
    s[i]--;
    for (int j = i + 1; j < n; j++) s[j] = '9';
    int sum = 0;
    for (int j = 0; j < n; j++) sum += s[j] - '0';
    if (sum > maxsum) {
      maxsum = sum;
      ans = s;
    }
  }
  if (ans[0] == '0') ans.erase(0, 1);
  cout << ans;
}
