#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("IMPOSSIBLE");
  exit(0);
}
char s[20];
void mi(int i) { s[i] = s[i] - '0' - 1 + '0'; }
int ji(int i) {
  if (s[i] == '0') return 0;
  int ss = 0;
  for (int(j) = 0; (j) < (int)(i); (j)++) ss += s[j] - '0';
  ss += s[i] - '0' - 1;
  for (int j = i + 1; j < n; j++) ss += 9;
  return ss;
}
void pp(int j) {
  mi(j);
  for (int i = j + 1; i < n; i++) s[i] = '9';
  if (s[0] == '0')
    puts(s + 1);
  else
    puts(s);
  exit(0);
}
void fmain(int tid) {
  scanf("%s", s);
  n = strlen(s);
  if (n == 1) {
    puts(s);
    return;
  } else {
    int tt = 0;
    for (int(i) = 0; (i) < (int)(n); (i)++) tt += s[i] - '0';
    int ss = s[0] - '0' - 1;
    for (int(i) = 1; (i) <= (int)(n - 1); (i)++) ss += 9;
    if (ss <= tt)
      puts(s);
    else {
      for (int j = n - 1; ~j; j--) {
        if (ji(j) == ss) pp(j);
      }
    }
  }
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
