#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, m;
  cin >> n;
  m = n;
  bool b = true, f = true;
  int x = n % 10;
  if (n > 0) {
    if (abs(m % 10) != 9) f = false;
    m /= 10;
    while (m != 0) {
      if (abs(m % 10) == 8) {
        if (!f) {
          b = false;
          cout << 1 << endl;
          break;
        }
      } else if (abs(m % 10) != 9)
        f = false;
      m = m / 10;
    }
  } else {
    if (n < 0) {
      if (abs(m % 10) != 0) f = false;
      m /= 10;
      while (m != 0) {
        if (abs(m % 10) == 8) {
          if (!f) {
            b = false;
            cout << 1 << endl;
            break;
          } else {
            if (abs(m % 10) != 0) f = false;
          }
        }
        m /= 10;
      }
    }
  }
  if (b) {
    if (n >= 0) {
      if (x >= 8) {
        if ((n % 100) / 10 == 7)
          cout << 10 - x << endl;
        else
          cout << 10 - (x - 8) << endl;
      } else {
        cout << 8 - (x) << endl;
      }
    } else {
      if (x < -8) {
        cout << -1 * x - 8 << endl;
      } else {
        if ((n % 100) / 10 == -9)
          cout << -1 * x + 1 << endl;
        else if (n >= -8)
          cout << -1 * n + 8 << endl;
        else
          cout << 10 - (8 - (-1 * x)) << endl;
      }
    }
  }
  return 0;
}
