#include <bits/stdc++.h>
using namespace std;
typedef struct st {
  int a;
  string b;
} st;
bool func(st x, st y) {
  if (x.a == y.a)
    return x.b > y.b;
  else
    return x.a > y.a;
}
int main() {
  string a;
  cin >> a;
  int sum1 = 0;
  for (int i = 0; i < a.size(); i++) sum1 += a[i] - 48;
  if (a.size() == 1) {
    cout << a;
    return 0;
  }
  vector<st> v(1);
  v[0].a = sum1;
  v[0].b = a;
  for (int i = a.size() - 2; i >= 0; i--) {
    string s;
    for (int j = 0; j <= i; j++) s += a[j];
    s[s.size() - 1]--;
    for (int j = i + 1; j < a.size(); j++) {
      char f = 48 + 9;
      s += f;
    }
    int sum2 = 0;
    for (int j = 0; j < s.size(); j++) sum2 += s[j] - 48;
    st x;
    x.a = sum2;
    x.b = s;
    v.push_back(x);
  }
  sort(v.begin(), v.end(), func);
  if (v[0].b[0] != '0')
    cout << v[0].b;
  else
    for (int i = 1; i < v[0].b.size(); i++) cout << v[0].b[i];
  return 0;
}
