#include <bits/stdc++.h>
int sum(int* ar, int n, int i) {
  int s = 0;
  if (ar[i] == 0) return -1;
  for (int j = 0; j < i; j++) {
    s += 9;
  }
  s += ar[i] - 1;
  for (int j = i + 1; j < n; j++) {
    s += ar[j];
  }
  return s;
}
int main() {
  long long x, y;
  int key = 0;
  int* ar;
  int l;
  scanf("%I64d", &x);
  y = x;
  while (y > 0) {
    y = y / 10;
    key++;
  }
  ar = new int[key];
  key = 0;
  y = x;
  while (y > 0) {
    ar[key] = y % 10;
    y = y / 10;
    key++;
  }
  l = 0;
  int n = key;
  for (int i = 1; i < n; i++) {
    if (sum(ar, n, i) > sum(ar, n, l)) {
      l = i;
    }
  }
  int r = 0;
  for (int i = 0; i < n; i++) {
    r += ar[i];
  }
  if (r >= sum(ar, n, l)) {
    for (int i = n - 1; i >= 0; i--) {
      printf("%d", ar[i]);
    }
    return 0;
  }
  for (int i = 0; i < l; i++) {
    ar[i] = 9;
  }
  ar[l] = ar[l] - 1;
  if (ar[n - 1] != 0) {
    printf("%d", ar[n - 1]);
  }
  for (int i = n - 2; i >= 0; i--) {
    printf("%d", ar[i]);
  }
  return 0;
}
