#include <bits/stdc++.h>
using namespace std;
long long num;
string s;
int n;
map<long long, string> mp;
long long dp[20][2][200];
long long solve(int pos, int isSmall, int sum, string str) {
  if (pos == n) {
    if (!mp[sum].length()) mp[sum] = str;
    return sum;
  }
  if (dp[pos][isSmall][sum] != -1) return dp[pos][isSmall][sum];
  long long ret = 0;
  int lim = 9;
  if (!isSmall) lim = s[pos] - '0';
  for (int num = lim; num >= 0; num--) {
    int flag = isSmall;
    if (!flag && num < lim) flag = true;
    char ch = (num + '0');
    ret = max(ret, solve(pos + 1, flag, sum + num, str + ch));
  }
  return dp[pos][isSmall][sum] = ret;
}
int main() {
  memset(dp, -1, sizeof dp);
  cin >> num;
  s = to_string(num);
  n = s.length();
  num = solve(0, 0, 0, "");
  s = mp[num];
  long long x = 0;
  for (int i = 0; i < s.length(); i++) x = (x * 10) + (s[i] - '0');
  cout << x << endl;
}
