#include <bits/stdc++.h>
using namespace std;
int sum(long long int l) {
  int k = 0;
  while (l) {
    k += l % 10;
    l /= 10;
  }
  return k;
}
int main() {
  long long int n;
  cin >> n;
  long long int maxi = n;
  for (long long int i = 10; i <= n; i *= 10) {
    long long int t = (n / i) * i - 1;
    if (sum(maxi) < sum(t)) {
      maxi = t;
    }
  }
  cout << maxi;
  return 0;
}
