#include <bits/stdc++.h>
int main(int argc, char *argv[]) {
  long long i, max = 0, sum = 0, maxL, j, Len, noL;
  char num[20], maxNum[20];
  scanf("%s", num);
  strcpy(maxNum, num);
  Len = strlen(num);
  for (i = 0; i < Len; i++) {
    max += (int)num[i] - 48;
  }
  for (j = Len - 2; j >= 0; j--) {
    sum = 0;
    for (i = Len - 1; i > j; i--) {
      num[i] = '9';
    }
    num[j] = (char)((int)num[j] - 1);
    for (i = 0; i < Len; i++) {
      sum += (int)num[i] - 48;
    }
    if (max < sum) {
      max = sum;
      strcpy(maxNum, num);
    }
  }
  for (i = 0; i < Len; i++) {
    if (i == 0 && maxNum[i] == '0') {
      continue;
    } else {
      printf("%c", maxNum[i]);
    }
  }
  return 0;
}
