#include <bits/stdc++.h>
using namespace std;
long long a;
char s[20];
bool check(int x) {
  while (x > 0) {
    int y = x % 10;
    x /= 10;
    if (y == 8) return true;
  }
  return false;
}
int main() {
  cin >> s;
  if (s[0] == '-') {
    int cnt = 1;
    for (int i = strlen(s) - 1; i > 0; i--) {
      int c = s[i] - '0';
      a += c * cnt;
      cnt *= 10;
    }
    if (a <= 8) {
      int x = sqrt(a * a);
      printf("%d", 8 + x);
      return 0;
    }
    int x = sqrt(a * a);
    if (x == 9) {
      printf("%d", 1);
      return 0;
    }
    for (int i = 1; i <= 10; i++) {
      if (check(x - i)) {
        printf("%d", i);
        return 0;
      }
    }
  }
  int cnt = 1;
  for (int i = strlen(s) - 1; i >= 0; i--) {
    int c = s[i] - '0';
    a += c * cnt;
    cnt *= 10;
  }
  for (int i = 1; i <= 10; i++) {
    if (check(a + i)) {
      printf("%d", i);
      return 0;
    }
  }
  return 0;
}
