#include <bits/stdc++.h>
using namespace std;
unsigned long long x;
vector<int> a;
vector<pair<int, vector<int> > > sums;
int sumN(vector<int> &r) {
  int ch = 0;
  for (int i = 0; i < r.size(); i++) ch += r[i];
  return ch;
}
int main() {
  cin >> x;
  while (x > 0) {
    a.push_back(x % 10);
    x /= 10;
  }
  if (a.size() == 1)
    cout << a[0];
  else {
    reverse(a.begin(), a.end());
    int s;
    s = sumN(a);
    sums.push_back(make_pair(s, a));
    for (int i = a.size() - 2; i >= 0; i--) {
      if (a[i] == 0)
        a[i + 1] = 9;
      else {
        a[i]--;
        a[i + 1] = 9;
        s = sumN(a);
        sums.push_back(make_pair(s, a));
      }
    }
    sort(sums.begin(), sums.end());
    if (sums[sums.size() - 1].second[0] == 0)
      for (int i = 1; i < sums[sums.size() - 1].second.size(); i++)
        cout << sums[sums.size() - 1].second[i];
    else
      for (int i = 0; i < sums[sums.size() - 1].second.size(); i++)
        cout << sums[sums.size() - 1].second[i];
  }
  return 0;
}
