#include <bits/stdc++.h>
using namespace std;
int check(long long a) {
  int ans = 0;
  a = abs(a);
  while (a) {
    if (a % 10 == 8) ans = 1;
    a /= 10;
  }
  return ans;
}
int main() {
  long long a;
  cin >> a;
  for (long long i = 1; i < 10000000; i++) {
    if (check(a + i)) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
