#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  char str[20];
  scanf("%s", str);
  int len = strlen(str);
  int was = 0;
  int i;
  for (i = 1; i < len; ++i) {
    if (str[i] == '9') {
      continue;
    } else if (str[i] == '8' && !was) {
      was = i;
    } else {
      break;
    }
  }
  if (str[i] == 0) {
    printf("%s\n", str);
    return 0;
  }
  if (was) {
    --str[was - 1];
    for (i = was; i < len; ++i) {
      str[i] = '9';
    }
  } else {
    --str[i - 1];
    for (i; i < len; ++i) {
      str[i] = '9';
    }
  }
  printf("%s\n", str[0] == '0' ? str + 1 : str);
  return 0;
}
