#include <bits/stdc++.h>
using namespace std;
int sum(long long int a) {
  int r = 0;
  while (a > 0) {
    r += a % 10;
    a /= 10;
  }
  return r;
}
void solve(long long int n) {
  int i, j, k, q = 0, w = 0, m, x, y;
  long long int ans = n, s = 1;
  q = sum(n);
  while (n > 0) {
    n /= 10;
    s *= 10;
    if (sum(n * s - 1) > q) {
      q = sum(n * s - 1);
      ans = n * s - 1;
    }
  }
  printf("%I64d", ans);
}
int main() {
#pragma warning(disable : 4996);
  long long int n;
  while (scanf("%I64d", &n) != EOF) {
    solve(n);
    return 0;
    printf("\n");
  }
  return 0;
}
