#include <bits/stdc++.h>
using namespace std;
long long findsum(string s) {
  long long sum = 0;
  for (long long i = 0; i < s.length(); i++) sum += s[i] - '0';
  return sum;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  string s = to_string(n);
  long long l = s.length();
  vector<pair<long long, long long>> v;
  v.push_back({findsum(s), stoll(s)});
  for (long long i = l - 1; i >= 0; i--) {
    string temp = "";
    if (s[i] - '0' > 0) {
      temp += s.substr(0, i);
      char c = s[i] - 1;
      temp = temp + c;
      temp = temp + string(l - 1 - i, '9');
    }
    if (temp.length()) v.push_back({findsum(temp), stoll(temp)});
  }
  sort(v.rbegin(), v.rend());
  cout << v[0].second << "\n";
}
