#include <bits/stdc++.h>
const int mx = 1e5 + 10;
using namespace std;
long long a[mx];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long x, result = 0, n, k = 1;
  cin >> x;
  n = x;
  while (n / 10 != 0) {
    result += 9 * k;
    k *= 10;
    n /= 10;
  }
  result += k * n;
  if (x == result) {
    cout << x << endl;
    return 0;
  }
  result--;
  k = 1;
  while (result > x) {
    result -= 9 * k;
    k *= 10;
  }
  cout << result << endl;
  return 0;
}
