#include <bits/stdc++.h>
using namespace std;
long long sum(long long a) {
  int cnt = 0;
  while (a) {
    cnt += a % 10;
    a /= 10;
  }
  return cnt;
}
int main() {
  long long n, k = 1, ans, s = 0;
  cin >> n;
  ans = n;
  s = sum(n);
  while (n > 9) {
    k *= 10;
    n /= 10;
    long long m = n * k - 1;
    if (sum(m) > s) {
      ans = m;
      s = sum(m);
    }
  }
  cout << ans;
  return 0;
}
