#include <bits/stdc++.h>
using namespace ::std;
void separateToSymbols(vector<int>& symbols, long long x) {
  vector<int> reversedNum;
  while (x) {
    reversedNum.push_back(x % 10);
    x = x / 10;
  }
  for (int i = reversedNum.size() - 1; i >= 0; i--) {
    symbols.push_back(reversedNum[i]);
  }
  return;
}
bool isOnlyOne8andMany9(vector<int>& symbols) {
  bool is8 = false;
  for (int i = 1; i < symbols.size(); i++) {
    if (is8) {
      if (symbols[i] != 9) {
        return false;
      }
    } else {
      if (symbols[i] == 8) {
        is8 = true;
      } else {
        if (symbols[i] == 9) {
          continue;
        } else {
          return false;
        }
      }
    }
  }
  return is8;
}
void printTypeA(vector<int>& symbols) {
  cout << symbols[0];
  bool isNextOnly9 = false;
  for (int i = 1; i < symbols.size(); i++) {
    if (isNextOnly9) {
      cout << 9;
      continue;
    } else {
      if (symbols[i] == 9) {
        if (i + 1 < symbols.size()) {
          if (symbols[i + 1] == 9) {
            cout << 9;
          } else {
            cout << 8;
            isNextOnly9 = true;
          }
        } else {
          cout << 9;
          return;
        }
      } else {
        isNextOnly9 = true;
        cout << 9;
      }
    }
  }
  return;
}
void printTypeB(vector<int>& symbols) {
  if (symbols[0] != 1) {
    cout << symbols[0] - 1;
  }
  for (int i = 1; i < symbols.size(); i++) {
    cout << 9;
  }
  return;
}
void printSource(vector<int>& symbols) {
  for (int i = 0; i < symbols.size(); i++) {
    cout << symbols[i];
  }
  return;
}
int main() {
  long long x;
  cin >> x;
  if (x < 10) {
    cout << x;
    return 0;
  }
  vector<int> symbols;
  separateToSymbols(symbols, x);
  if (symbols[1] == 9) {
    if (isOnlyOne8andMany9(symbols)) {
      printSource(symbols);
      return 0;
    } else {
      printTypeA(symbols);
      return 0;
    }
  } else {
    if (symbols[1] == 8) {
      if (isOnlyOne8andMany9(symbols)) {
        printSource(symbols);
        return 0;
      } else {
        for (int i = 0; i < symbols.size(); i++) {
          if (symbols[i] != 9) {
            printTypeB(symbols);
            return 0;
          }
        }
        printTypeA(symbols);
        return 0;
      }
    } else {
      printTypeB(symbols);
      return 0;
    }
  }
  return 0;
}
