#include <bits/stdc++.h>
using namespace std;
long long int x[1000007], y[1000007], z[1000007], n;
string s, S, anss;
vector<long long int> v;
int main() {
  {
    long long int a = 0, b = 0, c = 0, d, e, f, g, i, j, k, l, m, p, q = 0, r,
                  u, w, t, tc, in, mod, loc, diff, val, sz, lo, hi, mid,
                  mn = 2134567891, mx = 0, sum = 0, ans = 0;
    cin >> s;
    l = s.size();
    anss = s;
    for (i = 0; i < l; i++) ans += s[i] - 48;
    for (i = l - 1; i >= 0; i--) {
      p = q;
      if (s[i] > 48) {
        p += s[i] - 49;
        for (j = i - 1; j >= 0; j--) {
          p += s[j] - 48;
        }
        if (p > ans) {
          S.clear();
          for (j = 0; j < i; j++) S += s[j];
          S += (s[i] - 1);
          for (j = i + 1; j < l; j++) S += '9';
          anss = S;
          ans = p;
        }
      }
      q += 9;
    }
    if (anss[0] == '0')
      for (i = 1; i <= l - 1; i++) cout << anss[i];
    else
      cout << anss;
  }
  return 0;
}
