#include <bits/stdc++.h>
using namespace std;
unsigned long long n;
unsigned long long getNumber() {
  unsigned long long t = n;
  int digit;
  int sum = 0;
  int length = 0;
  int flag = 0;
  int ten = 1;
  unsigned long long preresult = 0;
  while (t != 0) {
    digit = t % 10;
    sum += digit;
    t /= 10;
    if (digit == 9 && flag == 0) flag = length;
    if (flag != 0 && digit != 9 && t != 0) {
      flag = 0;
    }
    length++;
  }
  unsigned long long result = 0;
  if ((length - 1) * 9 + (digit - 1) > sum) {
    if (flag == 0 || flag == length - 1) {
      result = digit - 1;
      for (int i = 0; i < length - 1; i++) result = result * 10 + 9;
    } else {
      result = digit;
      for (int i = 0; i < length - flag - 2; i++) result = result * 10 + 9;
      result = result * 10 + 8;
      for (int i = 0; i < flag; i++) result = 10 * result + 9;
    }
  } else
    result = n;
  return result;
}
int main() {
  cin >> n;
  cout << getNumber();
  return 0;
}
