#include <bits/stdc++.h>
using namespace std;
long long md = 1e9 + 7;
long long md2 = 1e9 + 9;
string s;
int get_s(string ss) {
  int sum = 0;
  for (int i(0); i < ss.length(); i++) sum += (ss[i] - '0');
  return sum;
}
string get_max(string x) {
  string start = x;
  string ans = s;
  int ind = (int)x.length() - 1;
  while (ind >= 0) {
    int in = (x[ind] - '0');
    if (in != 0) in--;
    x[ind] = (in + '0');
    for (int i((int)x.length() - 1); i > ind; i--) x[i] = '9';
    if (get_s(x) > get_s(ans)) ans = x;
    ind--;
  }
  int indexx = 0;
  while (ans[indexx] == '0') indexx++;
  string all_ans;
  for (int i(indexx); i < ans.length(); i++) all_ans += ans[i];
  return (all_ans);
}
int main() {
  cin >> s;
  if (s == "1") return cout << 1, 0;
  if (s[0] == '1' && s[1] <= '7') {
    for (int i(0); i < s.length() - 1; i++) cout << 9;
    return 0;
  }
  cout << get_max(s) << "\n";
  return 0;
}
