#include <bits/stdc++.h>
int main() {
  char x[20];
  scanf("%s", x);
  int i;
  int ct8 = 0, ct9 = 0;
  int length = strlen(x);
  for (i = 1; i < length; i++) {
    if (x[i] == '8')
      ct8++;
    else if (x[i] == '9')
      ct9++;
  }
  if (!(ct9 == length - 1 || (ct9 == length - 2 && ct8 == 1))) {
    if (x[1] == '9') {
      i = 1;
      while (x[i + 1] == '9') i++;
      x[i] = '8';
      i++;
      for (; i < length; i++) x[i] = '9';
    } else {
      for (i = 1; i < length; i++) x[i] = '9';
      x[0]--;
    }
  }
  if (x[0] == '0')
    i = 1;
  else
    i = 0;
  for (; i < length; i++) printf("%c", x[i]);
  printf("\n");
  return 0;
}
