#include <bits/stdc++.h>
using namespace std;
long long int T = 1, inf = 10000000000;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  while (T--) {
    long long int n, sz, ans = 0, blag = 0, u, mn, ev = 0, mx, mini, i, v, q, p,
                         j, k, w, h, l, m, x, y, od = 0, total = 0, cc = 0,
                         pp = 0, flag = 0, klag = 0, sum = 0;
    string s, s1 = "YES", s2 = "NO";
    bool ok = 0;
    n = 11;
    cin >> s;
    if (stoll(s, nullptr, 10) <= 9) {
      cout << s;
      break;
    }
    sz = s.size();
    string s3(sz - 1, '9');
    s3 = '0' + s3;
    for (i = 1; i < 10; i++) {
      s3[0]++;
      if (s3 > s) {
        for (j = sz - 1; j > 0; j--) {
          s3[j]--;
          if (s3 <= s) {
            flag = 1;
            break;
          } else {
            s3[j]++;
          }
        }
        if (flag == 0) {
          s3[0]--;
        }
        break;
      }
    }
    if (s3[0] == '0') {
      s3.erase(0, 1);
    }
    cout << s3 << "\n";
  }
  return 0;
}
