#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, x;
  cin >> n;
  vector<long long int> v;
  x = n;
  while (x != 0) {
    v.push_back(x % 10);
    x /= 10;
  }
  reverse(v.begin(), v.end());
  long long int res = accumulate(v.begin(), v.end(), 0LL);
  map<long long int, long long int, greater<long long int> > mp;
  long long int ans = max(res, ans);
  mp[n] = res;
  for (long long int i = v.size() - 1; i >= 1; i -= 1) {
    v[i] = 9;
    v[i - 1] -= 1;
    long long int sum = accumulate(v.begin(), v.end(), 0LL), num = 0;
    for (long long int j : v) num = num * 10 + j;
    mp[num] = sum;
    ans = max(sum, ans);
  }
  for (auto i : mp)
    if (ans == i.second) {
      cout << i.first << endl;
      break;
    }
  return 0;
}
