#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long i = n;
  bool t = true;
  while (t) {
    i++;
    long long y = i;
    while (y / 10 != 0) {
      int d = y % 10;
      y /= 10;
      if (d == -8 || d == 8) {
        t = false;
        break;
      }
    }
    int d = y % 10;
    if (d == -8 || d == 8) {
      t = false;
      break;
    }
  }
  cout << i - n << endl;
  return 0;
}
