#include <bits/stdc++.h>
using namespace std;
char str[20];
int mem[20][200][2];
int dp(int pos, int sum, bool f) {
  if (pos == strlen(str)) return sum;
  if (mem[pos][sum][f] != -1) return mem[pos][sum][f];
  mem[pos][sum][f] = 0;
  if (f)
    mem[pos][sum][f] = dp(pos + 1, sum + 9, f);
  else {
    mem[pos][sum][f] = dp(pos + 1, sum + (str[pos] - '0'), f);
    for (int i = str[pos] - '1'; i >= 0; i--)
      mem[pos][sum][f] = max(mem[pos][sum][f], dp(pos + 1, sum + i, 1));
  }
  return mem[pos][sum][f];
}
queue<int> q;
void print(int pos, int sum, bool f) {
  if (pos == strlen(str)) return;
  if (f)
    q.push(9), print(pos + 1, sum + 9, f);
  else {
    if (mem[pos][sum][f] == dp(pos + 1, sum + (str[pos] - '0'), f))
      q.push(str[pos] - '0'), print(pos + 1, sum + (str[pos] - '0'), f);
    else {
      for (int i = str[pos] - '1'; i >= 0; i--)
        if (mem[pos][sum][f] == dp(pos + 1, sum + i, 1)) {
          q.push(i);
          print(pos + 1, sum + i, 1);
          return;
        }
    }
  }
}
int main() {
  memset(mem, -1, sizeof mem);
  scanf("%s", str);
  dp(0, 0, 0);
  print(0, 0, 0);
  if (q.front() == 0) q.pop();
  while (!q.empty()) printf("%d", q.front()), q.pop();
  puts("");
  return 0;
}
