#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T& x) {
  int f = 1;
  x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
const int N = 30;
long long x;
int cnt;
int ans[N], c[N], a[N];
int check() {
  int sa = 0, sb = 0;
  for (int i = 1; i <= cnt; i++) sa += ans[i];
  for (int i = 1; i <= cnt; i++) sb += c[i];
  return sb >= sa;
}
int main() {
  read(x);
  if (x == 0) {
    printf("0\n");
    return 0;
  }
  while (x) a[++cnt] = x % 10, x /= 10;
  for (int i = 1; i <= cnt; i++) ans[i] = a[i];
  for (int i = cnt; i; i--) {
    if (a[i] == 0) continue;
    for (int j = 1; j <= cnt; j++) c[j] = a[j];
    for (int j = 1; j < i; j++) c[j] = 9;
    c[i]--;
    if (check())
      for (int j = 1; j <= cnt; j++) ans[j] = c[j];
  }
  for (int i = 1; i <= cnt; i++) c[i] = a[i];
  if (check())
    for (int j = 1; j <= cnt; j++) ans[j] = c[j];
  for (int i = ans[cnt] ? cnt : cnt - 1; i; i--) printf("%d", ans[i]);
  printf("\n");
  return 0;
}
