#include <bits/stdc++.h>
using namespace std;
const int N = 200009;
int check(string s) {
  int ans = 0;
  for (int i = 0; i <= (int)((s).size()) - 1; ++i) ans += s[i] - '0';
  return ans;
}
int main() {
  string s;
  cin >> s;
  int best = check(s);
  string ans = s;
  for (int i = (int)((s).size()) - 1; i >= 0; --i)
    if (s[i]) {
      for (int j = i + 1; j <= (int)((s).size()) - 1; ++j) s[j] = '9';
      s[i]--;
      if (check(s) > best) {
        best = check(s);
        ans = s;
      }
    }
  if (ans[0] == '0' && (int)((ans).size()) > 1) ans = ans.substr(1);
  cout << ans << endl;
}
