#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  int c = 0;
  if (x.size() == 1) {
    cout << x[0] << endl;
    return 0;
  }
  if (x.size() == 2) {
    if (x[1] >= '8')
      cout << x << endl;
    else {
      if (x[0] < '2')
        cout << "9" << endl;
      else
        cout << x[0] - '1' << "9" << endl;
    }
    return 0;
  }
  if (x.size() == 3) {
    if (x[1] == '9' && x[2] >= '8' || (x[1] == '8' && x[2] >= '9')) {
      cout << x << endl;
      return 0;
    }
  }
  for (int h = 1; h < x.size(); h++) {
    if (x[h] != '9') {
      c++;
      break;
    }
  }
  unsigned long long int bb = 0, cc = 0;
  for (int ii = 0; ii < x.size(); ii++) {
    cc += x[ii] - '0';
  }
  int index = 0, nn = 0;
  ;
  for (int i = 0; i < x.size(); i++) {
    if (x[1] == '9' && nn == 0) {
      nn++;
      for (int j = 1; j < x.size(); j++) {
        if (x[j] == '9')
          continue;
        else {
          index = j;
          break;
        }
      }
    }
    if (i == 0) {
      if (c == 0) {
        bb = x[i] - '0';
        continue;
      }
      if (c != 0) {
        if (x[i] == '1')
          continue;
        else {
          int d = x[i] - '0' - 1;
          bb = d;
          continue;
        }
        continue;
      }
    }
    bb = bb + 9;
  }
  if (cc >= bb) {
    cout << x << endl;
    return 0;
  }
  int gg = 0;
  for (int i = 0; i < x.size(); i++) {
    if (x[1] == '9' && gg == 0) {
      if (i == index - 1) {
        cout << "8";
        gg++;
      } else
        cout << x[i];
      continue;
    }
    if (i == 0) {
      if (c == 0) {
        cout << x[i];
        bb = x[i] - '0';
        continue;
      }
      if (c != 0) {
        if (x[i] == '1')
          continue;
        else {
          int d = x[i] - '0' - 1;
          cout << d;
          bb = d + 1;
          continue;
        }
        continue;
      }
    }
    cout << "9";
    bb = bb + 9;
  }
  cout << endl;
  return 0;
}
