#include <bits/stdc++.h>
using namespace std;
void splitstr(const string &s, vector<string> &v) {
  istringstream in(s);
  copy(istream_iterator<string>(in), istream_iterator<string>(),
       back_inserter(v));
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << *it << " = " << a << '\n';
  err(++it, args...);
}
struct point {
  int x, y;
  double len() { return sqrt(x * x + y * y); }
  double angel() { return atan2(y, x); }
  point operator+(const point &o) { return {x + o.x, y + o.y}; }
  point operator*(const int d) { return {x * d, y * d}; }
  int operator*(const point &o) { return x * o.x + y * o.y; }
  int operator^(const point &o) { return x * o.y - y * o.x; }
};
const int maxn = (1e5) + 100;
const long long INF = (1e9) + 7;
const long double EPS = 1e-8;
pair<int, int> solveEasy(int n) {
  int ans = 0;
  int k = n;
  while (n > 0) {
    ans += n % 10;
    n /= 10;
  }
  return {ans, k};
}
vector<int> answer;
vector<int> num;
void getNum(long long n) {
  if (n == 0) {
    num.push_back(0);
    return;
  }
  while (n > 0) {
    num.push_back(n % 10);
    n /= 10;
  }
  reverse(num.begin(), num.end());
  return;
}
bool checkNine(int pos) {
  for (int i = pos; i < num.size(); i++) {
    if (num[i] != 9) {
      return false;
    }
  }
  return true;
}
void solve(int i) {
  if (i == num.size() - 1) {
    answer.push_back(num[i]);
    return;
  }
  if (num[i + 1] < 8) {
    answer.push_back(num[i] - 1);
    for (int j = i + 1; j < num.size(); j++) {
      answer.push_back(9);
    }
    return;
  }
  if (num[i + 1] == 8) {
    if (checkNine(i + 2)) {
      for (int j = i; j < num.size(); j++) {
        answer.push_back(num[j]);
      }
    } else {
      answer.push_back(num[i] - 1);
      for (int j = i + 1; j < num.size(); j++) {
        answer.push_back(9);
      }
    }
    return;
  }
  if (num[i + 1] == 9) {
    answer.push_back(num[i]);
    solve(i + 1);
  }
  return;
}
long long getAns() {
  long long ans = 0;
  for (int i = 0; i < (int)answer.size(); i++) {
    ans *= 10;
    ans += answer[i];
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  getNum(n);
  solve(0);
  cout << getAns();
  return 0;
}
