#include <bits/stdc++.h>
char num[20];
int help(int pos, int n) {
  if (num[pos] == '0') return -1;
  int ans = 0;
  for (int i = 0; i < pos; i++) ans += num[i] - '0';
  return ans + num[pos] - '1' + 9 * (n - 1 - pos);
}
char* solve() {
  int n(strlen(num)), ans = 0, p = -1;
  for (int i = 0; i < n; i++) ans += num[i] - '0';
  for (int i = n - 2; i >= 0; i--) {
    int t = help(i, n);
    if (ans < t) {
      ans = t;
      p = i;
    }
  }
  if (p >= 0) {
    num[p]--;
    for (int i = p + 1; i < n; i++) num[i] = '9';
  }
  char* v = num;
  while (*v == '0') v++;
  return v;
}
int main() {
  scanf("%s", num);
  puts(solve());
}
