#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, rez = "";
  cin >> s;
  int l = s.length();
  int* sum = new int[l];
  sum[l - 1] = 0;
  for (int i = 0; i < l - 1; i++) {
    sum[i] = 0;
    for (int j = 0; j < i; j++) sum[i] += s[j] - '0';
    if (i == 0) {
      if (s[0] != '1') sum[i] += s[0] - '0' - 1;
    } else
      sum[i] += s[i] - '0' - 1;
    for (int j = i + 1; j < l; j++) sum[i] += 9;
  }
  for (int i = 0; i < l; i++) sum[l - 1] += s[i] - '0';
  int maxi = 0;
  for (int i = 1; i < l; i++) {
    if (sum[i] >= sum[maxi]) maxi = i;
  }
  if (maxi == l - 1)
    cout << s;
  else {
    for (int i = 0; i < maxi; i++) cout << s[i];
    if (maxi == 0) {
      if (s[0] != '1') cout << s[0] - '0' - 1;
    } else
      cout << s[maxi] - '0' - 1;
    for (int i = maxi + 1; i < l; i++) cout << '9';
  }
  return 0;
}
