#include <bits/stdc++.h>
const long long int mrx = 1e6 + 5, M = 1e9 + 7, dm = 1e3 + 5;
const long double pi = 3.1415926535897932384626433832795028841971693993751;
long long int mx = -1e18 - 1, mn = 1e18 + 1;
using namespace std;
string s;
bool f;
long long int id, cnt, d, z;
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cin >> s;
  while (s[0] == '0') {
    s.erase(0, 1);
  }
  if (s[0] == '1' && s[1] == '8') {
    for (long long int i = 2; i < s.size(); ++i) {
      if (s[i] != '9') {
        z = 1;
        break;
      }
    }
    if (z == 0) {
      cout << s;
      return 0;
    }
  }
  if (s.size() == 1) {
    cout << s;
    return 0;
  }
  if (s[0] == '1' && s[1] != '9') {
    for (long long int i = 0; i < s.size() - 1; ++i) {
      cout << 9;
    }
    return 0;
  }
  f = true;
  for (long long int i = 1; i < s.size(); ++i) {
    if (s[i] != '9') {
      f = false;
      id = i;
      break;
    }
  }
  if (f) {
    cout << s;
    return 0;
  }
  for (long long int i = 1; i < s.size(); ++i) {
    if (s[i] != '9') {
      cnt++;
      if (s[i] == '8') {
        d++;
      }
    }
  }
  if (cnt == 1 && d == 1) {
    cout << s;
    return 0;
  }
  s[id - 1] = char(s[id - 1] - 1);
  while (s[0] == '0') {
    s.erase(0, 1);
    id--;
  }
  for (long long int i = id; i < s.size(); ++i) {
    s[i] = '9';
  }
  cout << s;
  return 0;
}
