#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const int INF = 105000;
int s(long long x) {
  int sum = 0;
  while (x) {
    sum += x % 10;
    x /= 10;
  }
  return sum;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, su = 0;
  cin >> n;
  if (n < 10) {
    cout << n;
    return 0;
  }
  su = s(n);
  long long ans = n;
  for (long long i = 10; i <= n; i *= 10) {
    long long rofl = n - n % i - 1;
    if (s(rofl) > su) {
      su = s(rofl);
      ans = rofl;
    }
  }
  cout << ans;
}
