Giga Tower is the tallest and deepest building in Cyberland. There are 17 777 777 777 floors, numbered from  - 8 888 888 888 to 8 888 888 888. In particular, there is floor 0 between floor  - 1 and floor 1. Every day, thousands of tourists come to this place to enjoy the wonderful view. In Cyberland, it is believed that the number "8" is a lucky number (that's why Giga Tower has 8 888 888 888 floors above the ground), and, an integer is lucky, if and only if its decimal notation contains at least one digit "8". For example, 8,  - 180, 808 are all lucky while 42,  - 10 are not. In the Giga Tower, if you write code at a floor with lucky floor number, good luck will always be with you (Well, this round is #278, also lucky, huh?).Tourist Henry goes to the tower to seek good luck. Now he is at the floor numbered a. He wants to find the minimum positive integer b, such that, if he walks b floors higher, he will arrive at a floor with a lucky number.

The only line of input contains an integer a ( - 109 ≤ a ≤ 109).

NoteFor the first sample, he has to arrive at the floor numbered 180.For the second sample, he will arrive at 8.Note that b should be positive, so the answer for the third sample is 10, not 0.

using System;

namespace A488
{
    class Program
    {
        static void Main(string[] args)
        {
            long a = Convert.ToInt64(Console.ReadLine());
            long b = 1;

            for (long i = a + 1; i < 8888888888; i++)            {

                if (i.ToString().Contains("8"))
                    break;
                b++;
            }
            Console.Write(b);
        }
    }
}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.Remoting.Services;
using System.Text;
using System.Xml.Linq;

#region ioh

class Scanner
{
    private readonly TextReader reader;
    private string[] buffer;
    private int bufferPos;

    public Scanner()
        : this(null)
    { }

    public Scanner(TextReader reader)
    {
        this.reader = reader ?? Console.In;
        buffer = new string[0];
    }

    public string NextTerm()
    {
        if (bufferPos >= buffer.Length)
        {
            buffer = reader.ReadLine().Split(' ');
            bufferPos = 0;
        }

        return buffer[bufferPos++];
    }

    public int NextInt()
    {
        return int.Parse(NextTerm());
    }

    public int[] NextIntArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    }

    public int[][] NextIntMatrix(int rowCount)
    {
        var matrix = new int[rowCount][];

        for (int i = 0; i < matrix.Length; i++)
        {
            matrix[i] = NextIntArray();
        }

        return matrix;
    }
}

#endregion

class Program
{
    private static readonly Scanner s = new Scanner();

    private static void Main(string[] args)
    {
        var s = int.Parse(Console.ReadLine())+1;
        var a = 1;

        while (!(c(s, 8)))
        {
            a++;
            s++;
        }

        Console.WriteLine(a);
    }

    static bool c(int a, int x)
    {
        a = Math.Abs(a);

        if (a == x) return true;

        while (a>0)
        {
            if (a%10 == x) return true;
            a /= 10;
        }

        return false;
    }
}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.Remoting.Services;
using System.Text;
using System.Xml.Linq;

#region ioh

class Scanner
{
    private readonly TextReader reader;
    private string[] buffer;
    private int bufferPos;

    public Scanner()
        : this(null)
    { }

    public Scanner(TextReader reader)
    {
        this.reader = reader ?? Console.In;
        buffer = new string[0];
    }

    public string NextTerm()
    {
        if (bufferPos >= buffer.Length)
        {
            buffer = reader.ReadLine().Split(' ');
            bufferPos = 0;
        }

        return buffer[bufferPos++];
    }

    public int NextInt()
    {
        return int.Parse(NextTerm());
    }

    public int[] NextIntArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    }

    public int[][] NextIntMatrix(int rowCount)
    {
        var matrix = new int[rowCount][];

        for (int i = 0; i < matrix.Length; i++)
        {
            matrix[i] = NextIntArray();
        }

        return matrix;
    }
}

#endregion

class Program
{
    private static readonly Scanner s = new Scanner();

    private static void Main(string[] args)
    {
        var s = int.Parse(Console.ReadLine());
        var a = 0;

        while (true)
        {
            a++;
            s++;
            if (s.ToString().Contains('8')) break;
        }

        Console.WriteLine(a);
    }
}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.Remoting.Services;
using System.Text;
using System.Xml.Linq;

#region ioh

class Scanner
{
    private readonly TextReader reader;
    private string[] buffer;
    private int bufferPos;

    public Scanner()
        : this(null)
    { }

    public Scanner(TextReader reader)
    {
        this.reader = reader ?? Console.In;
        buffer = new string[0];
    }

    public string NextTerm()
    {
        if (bufferPos >= buffer.Length)
        {
            buffer = reader.ReadLine().Split(' ');
            bufferPos = 0;
        }

        return buffer[bufferPos++];
    }

    public int NextInt()
    {
        return int.Parse(NextTerm());
    }

    public int[] NextIntArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    }

    public int[][] NextIntMatrix(int rowCount)
    {
        var matrix = new int[rowCount][];

        for (int i = 0; i < matrix.Length; i++)
        {
            matrix[i] = NextIntArray();
        }

        return matrix;
    }
}

#endregion

class Program
{
    private static readonly Scanner s = new Scanner();

    private static void Main(string[] args)
    {
        var s = int.Parse(Console.ReadLine());
        var a = 0;

        while (true)
        {
            a++;
            s++;
            if (c(s, 8)) break;
        }

        Console.WriteLine(a);
    }

    static bool c(int a, int x)
    {
        a = Math.Abs(a);

        if (a == x) return true;

        while (a>0)
        {
            if (a%10 == x) return true;
            a /= 10;
        }

        return false;
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace Giga_tower
{
    class Program
    {
        static void Main(string[] args)
        {
            var inicio = int.Parse(Console.ReadLine());
            var ans = 0;

            for (int i = 0; i <=16 ; i++)
            {
                if ((inicio + i).ToString().Contains('8') && i!=ans)
                {
                    Console.WriteLine(i);
                    return;
                }
            }

            Console.ReadKey();
        }
    }
}

using System;

class Program
{
    static void Main()
    {
        int result = 0;
        int n = int.Parse(Console.ReadLine());

        for (int i=n+1;i<n+100;i++)
        {
            if (i.ToString().Contains("8"))
            {
                result = i - n;
                break;
            }
        }
        Console.WriteLine(result);
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Codeforces9
{
    class Program
    {
        static void Main(string[] args)
        {
            int floor = Convert.ToInt32(Console.ReadLine());
            int b = Gigtown(floor);
            Console.WriteLine(b);

        }

        private static int Gigtown(int floor)
        {
            int b = 0;
            string str = "";
            while (true)
            {
                floor++;
                b++;
                str = floor.ToString();
                if (str.Contains("8"))
                {
                    break;
                }
            }
            //  Console.WriteLine(b);
            return b;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Codeforces9
{
    class Program
    {
        static void Main(string[] args)
        {
            //A. Гигабашня
            //Гигабашня — самое высокое и глубокое здание в Киберленде. В ней 17 777 777 777 этажей, пронумерованных от  - 8 888 888 888 до 8 888 888 888. В частности, между этажами  - 1 и 1 есть этаж 0. Тысячи туристов ежедневно приходят сюда, чтобы насладиться чудесным видом.

            //В Киберленде верят, что цифра «8» прносит удачу (именно поэтому в Гигабашне 8 888 888 888 этажей над землей), а целое число является счастливым тогда и только тогда, когда в его десятичной записи содержится по крайней мере одна цифра «8». Например, 8,  - 180, 808 — примеры счастливых чисел, а 42,  - 10 — нет. Когда вы пишете код на этаже со счастливым номером, с вами пребудет удача (да и этот раунд #278 тоже счастливый, не так ли?).

            //Турист Генри пришёл в башню за удачей. Сейчас он находится на этаже под номером a. Он хочет найти минимальное положительное целое число b, такое, что если он поднимется на b этажей вверх, он окажется на этаже со счастливым номером.

            //Входные данные
            //В единственной строке записано целое число a ( - 109 ≤ a ≤ 109).

            //Выходные данные
            //Выведите минимальное b.

            int floor = Convert.ToInt32(Console.ReadLine());
            int b = Gigtown(floor);
            Console.WriteLine(b);

        }

        private static int Gigtown(int floor)
        {
            int b = 0;
            while (true)
            {
                floor++;
                b++;
                string str = floor.ToString();
                if (str.Contains("8"))
                {
                    break;
                }
            }
            return b;
        }
    }
}

using System;
using System.Linq;

namespace CSharp
{
    public class _488A
    {
        public static void Main()
        {
            long a = long.Parse(Console.ReadLine());

            for (int b = 1; ; b++)
            {
                if ((a + b).ToString().Any(c => c == '8'))
                {
                    Console.WriteLine(b);
                    return;
                }
            }
        }
    }
}

// A Dynamic Programming based
// C# program to find minimum
// number operations to
// convert str1 to str2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Lap
{
    public int P;
    public int Q;

}
class GFG
{
    static string[] memo = new string[13];

    public static void Main()
    {
        bool check = false;
        var n = int.Parse(Console.ReadLine());
        int count = 0;

        count = 0;
        if (n < 0)
        {
            for (int i = n; i <= 1000000000; i++)
            {

                int num = Math.Abs(i);
                while (num > 0 && i > n)
                {
                    var digit = num % 10;
                    if (digit == 8)
                    {
                        check = true;
                        break;
                    }
                    num = num / 10;
                }

                if (check)
                    break;
                count++;

            }
            Console.Write(count);
            return;
        }
        if (n >= 0)
        {
            for (int i = n; i <= i + 10; i++)
            {

                int num = i;
                while (num > 0 && i > n)
                {
                    var digit = num % 10;
                    if (digit == 8)
                    {
                        check = true;
                        break;
                    }
                    num = num / 10;
                }

                if (check)
                    break;
                count++;

            }
            Console.Write(count);
            return;
        }

    }

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace codeforces
{
    class Program
    {
        static bool f(string s)
        {

            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == '8') return true;
            }
            return false;
        }
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int i = n+1;
            while (!f(i.ToString()))
            {
                i++;
            }
            Console.WriteLine(Math.Abs(i-n));
        }
    }
}

using System;

public class Test
{
	public static void Main()
	{
		long n = Convert.ToInt64(Console.ReadLine());
		int b=0;
		bool vodsem = true;
		while (vodsem)
		{
			b++;
			long xex = b+n;
		      while (Math.Abs(xex)>0)
		      {
		      	if(Math.Abs(xex)%10==8) vodsem=false;
		      	xex/=10;
		      }
		}
		Console.WriteLine(b);
	}
}

/*
 * Created by SharpDevelop.
 * User: ������
 * Date: 02.02.2016
 * Time: 21-30
 *
 * ������������ ����� �� ����� 4

A. ���������
��������� � ����� ������� � �������� ������ � ����������. � ��� 17,777,777,777 ������,
��������������� �� -8,888,888m888 �� 8,888,888,888. � ���������, ����� ������� -1 � 1 ���� ���� 0.
������ �������� ��������� �������� ����, ����� ����������� �������� �����.
� ���������� �����, ��� ����� �8� ������� ����� (������ ������� � ��������� 8,888,888,888 ������ ��� ������),
� ����� ����� �������� ���������� ����� � ������ �����, ����� � ��� ���������� ������ ���������� �� ������� ���� ���� ����� �8�.
��������, 8, -180, 808 � ������� ���������� �����, � 42, -10 � ���.
����� �� ������ ��� �� ����� �� ���������� �������, � ���� �������� ����� (�� � ���� ����� #278 ���� ����������, �� ��� ��?).
������ ����� ������ � ����� �� ������. ������ �� ��������� �� ����� ��� ������� a.
�� ����� ����� ����������� ������������� ����� ����� b, �����, ��� ���� �� ���������� �� b ������ �����,
�� �������� �� ����� �� ���������� �������.
������� ������
� ������������ ������ �������� ����� ����� a (?-?10^9???a???10^9).
�������� ������
�������� ����������� b.
������� ������
������� ������
179
�������� ������
1
������� ������
-1
�������� ������
9
������� ������
18
�������� ������
10
����������
� ������ ������� ����� ����� ����� �� ����� ����� 180.
�� ������ ������� � �� 8.
�������� ��������, ��� b ������ ���� ������������� ������, ��� ��� ����� � ������� ������� � 10, � �� 0.

-410058385

 */

using System;

class Program
{
	public static void Main(string[] args)
	{
		int n = int.Parse (Console.ReadLine ());
		int nn = n;

		for ( n++; ; n++ )
		{
			int m = Math.Abs (n);
//			Console.WriteLine (m);
			bool ok = false;
			while ( m > 0 )
			{
				if ( m % 10 == 8 )
				{
					ok = true;
					break;
				}
				m /= 10;
			}
			if ( ok )
				break;
		}

		Console.WriteLine (n - nn);
//		Console.ReadKey (true);
	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            long input = Int64.Parse(Console.ReadLine());
            long res = 0;
            for(long i = input+1; i <= 8888888888; i++)
            {
                if (i.ToString().Contains("8"))
                {
                    res += i-input;
                    break;
                }
            }
            Console.WriteLine(res);
            Console.ReadLine();
        }
    }
}

using System;
namespace Gigatower {
    class Program{
        public static int Main() {
            Int64 current_floor = Convert.ToInt64(Console.ReadLine());
            Int64 up_floors = 0;
            string buffer = "";
            while (true) {
                current_floor++;
                up_floors++;
                buffer = current_floor.ToString();
                if (buffer.Contains("8")) {
                    break;
                }
            }
            Console.WriteLine(up_floors);
            return 0;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Giga_Tower
{
    class Program
    {
        static void Main(string[] args)
        {
            int andar = int.Parse(Console.ReadLine());
            int NiveisSubidos = Operacao.VerificaNumero(andar, andar, 0);
            Console.WriteLine(NiveisSubidos);

        }

    }

    static class Operacao
    {
        public static int VerificaNumero(int a, int b, int contador)
        {

            string compara = Convert.ToString(a);
            if (compara.Contains("8") && a == b)
            {
                contador++;
                return VerificaNumero(a + 1, b, contador);
            }
            else if (compara.Contains("8"))
            {
                return contador;
            }
            else
            {
                contador++;
                return VerificaNumero(a + 1, b, contador);
            }

        }
    }

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Team_BruteForce_
{
    class Program
    {
        static void Main(string[] args)
        {
            int andar = int.Parse( Console.ReadLine() );
            int NiveisSubidos = Operacao.VerificaNumero(andar, andar, 0);
            Console.WriteLine(NiveisSubidos);

         }

    }

    static class Operacao
    {
        public static int VerificaNumero(int a,int b, int contador)
        {

            string compara = Convert.ToString(a);
            if (compara.Contains("8") && a == b)
            {
                contador++;
                return VerificaNumero(a + 1, b, contador);
           }
            else if (compara.Contains("8"))
            {
                return contador;
            }
            else
            {
                contador++;
                return VerificaNumero(a + 1, b, contador);
            }

        }
    }

}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace Giga_tower
{
    class Program
    {
        static void Main(string[] args)
        {
            var inicio = int.Parse(Console.ReadLine());

            for (int i = 0; i <=16 ; i++)
            {
                if ((inicio + i).ToString().Contains('8') && i!=0)
                {
                    Console.WriteLine(i);
                    return;
                }
            }

            Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            int n,i = 0;
            s = Console.ReadLine();
            n = Convert.ToInt32(s);
            bool x = true;
            while (x)
            {
                i++;
                n++;
                int j,temp = Math.Abs(n);
                while (temp>0)
                {
                    j = temp % 10;
                    if (j == 8)
                    {
                        x = false;
                        break;
                    }
                    temp /= 10;
                }
            }
            Console.Write(i);
            Console.WriteLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A.Giga_Tower
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int sum = 1;
            int z = n + 1;
            string x = Convert.ToString(z);
            while(true)
            {
                if(x.Contains('8'))
                {
                    break;
                }
                else
                {
                    sum++;
                    z += 1;
                    x = Convert.ToString(z);
                }
            }
            Console.WriteLine(sum);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Olimp2._1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            Int64 k = Int64.Parse(Console.ReadLine());
            int n = 0;
            bool p = false;
            for (; ; )
            {
                p = false;
                s = k.ToString();
                for (int i = 0; i < s.Length; i++)
                    if (s[i] == '8')
                        p = true;
                if ((p) && (n > 0))
                    break;
                k++;
                n++;
            }
            Console.WriteLine(n.ToString());

        }
    }
}

using System;
class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();//Console.In.ReadToEnd().Split(new char[] { '\n', '\r'}, StringSplitOptions.RemoveEmptyEntries);
            if (input[0] == '-')
            {
                if (input.Length == 2 && input[1] != '9')
                    Console.WriteLine((input[1] - 40));
                else
                {
                    int a = input.IndexOf('8');
                    if(a>=0)
                    {
                        if (a == input.Length - 1)
                        {
                            a = input.LastIndexOf('9');
                            if (a == -1) Console.WriteLine("10");
                            else
                            {
                                for (int i = a + 1, lim = input.Length - 1; i < lim; ++i)
                                    if (input[i] != '0') a = -1;
                                Console.WriteLine(a >= 0 ? "9" : "10");
                            }
                        }
                        else
                        {
                            for (int i = a + 1; i < input.Length; ++i)
                            {
                                if (input[i] != '0') { a = -1; break; }
                            }
                            Console.WriteLine(a >= 0 ? '2' : '1');
                        }
                    }
                    else
                    {
                        a = input.LastIndexOf('9');
                        if (a < 0) Console.WriteLine(input[input.Length - 1]-46);
                        else
                        {
                            if (input.Length - 1 == a) Console.WriteLine('1');
                            else
                            {
                                for (int i = a + 1, lim = input.Length-1; i < lim; ++i)
                                {
                                    if (input[i] != '0') { a = -1; break; }
                                }
                                Console.WriteLine(a ==input.Length-1? "1" : a>=0? (input[input.Length - 1] - 47).ToString(): (input[input.Length - 1] - 46).ToString());
                            }
                        }
                    }
                }
            }
            else
            {
                int a = input.IndexOf('8');
                if(a>=0)
                {
                    if(a==input.Length-1)
                    {
                        a = input.LastIndexOf('7');
                        if (a == -1) Console.WriteLine("10");
                        else
                        {
                            for (int i = a + 1, lim = input.Length - 1; i < lim; ++i)
                                if (input[i] != '9') a = -1;
                            Console.WriteLine(a >= 0 ? "2" : "10");
                        }
                    }
                    else
                    {
                        for (int i = a + 1; i < input.Length; ++i)
                        {
                            if (input[i] != '9') { a = -1; break; }
                        }
                        Console.WriteLine(a >= 0 ?'9':'1');
                    }
                }
                else
                {
                    a = input.LastIndexOf('7');
                    if (a < 0) Console.WriteLine(input[input.Length - 1] == '9' ? 9 : 56 - input[input.Length - 1]);
                    else
                    {
                        for (int i = a + 1; i < input.Length; ++i)
                        {
                            if (input[i] != '9') { a = -1; break; }
                        }
                        Console.WriteLine(a >= 0 ? "1" : (56-input[input.Length-1]).ToString());
                    }
                }
            }
        }
    }

using System;

namespace Question1
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            long input = long.Parse(str);
            long count = 0;

            do
            {
                input++;
                str = input.ToString();
                count++;
            } while (!str.Contains("8"));

            Console.WriteLine(count);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _488A
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = 0;
            n = Convert.ToInt64(Console.ReadLine());
            int a = 1;
            while (Eight(n+a)==0)
            {
                a++;
            }
            Console.WriteLine(a.ToString());

        }
        private static int Eight(long n)
        {
            if (n<0)
            {
                n = -n;
            }
            while (n!=0)
            {
                if (n%10==8)
                {
                    return 1;
                }
                n = n / 10;
            }
            return 0;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using Solver.Ex;
using Debug = System.Diagnostics.Debug;
using Watch = System.Diagnostics.Stopwatch;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
namespace Solver
{
    public class Solver
    {

        public void Solve()
        {
            var a= sc.Long();
            for (int i = 1; true; i++)
            {
                a++;
                if(a.ToString().Any(x=>x=='8'))
                {
                    IO.Printer.Out.WriteLine(i);
                    return;
                }
            }

        }
        internal IO.StreamScanner sc;
        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) a[i] = f(i); return a; }
    }

    #region Main and Settings
    static class Program
    {
        static void Main(string[] arg)
        {
#if DEBUG
            var errStream = new System.IO.FileStream(@"..\..\dbg.out", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
            Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, "debugStream"));
            Debug.AutoFlush = false;
            var sw = new Watch(); sw.Start();
            IO.Printer.Out.AutoFlush = true;
            try
            {
#endif

                var solver = new Solver();
                solver.sc = new IO.StreamScanner(Console.OpenStandardInput());
                solver.Solve();
                IO.Printer.Out.Flush();
#if DEBUG
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                Console.Error.WriteLine(ex.StackTrace);
            }
            finally
            {
                sw.Stop();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Error.WriteLine("Time:{0}ms", sw.ElapsedMilliseconds);
                Debug.Close();
                System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
            }
#endif
        }

    }
    #endregion
}

#region IO Helper
namespace Solver.IO
{
    public class Printer : System.IO.StreamWriter
    {
        static Printer()
        {
            Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
#if DEBUG
            Error = new Printer(Console.OpenStandardError()) { AutoFlush = true };
#else
            Error = new Printer(System.IO.Stream.Null) { AutoFlush = false };
#endif
        }
        public static Printer Out { get; set; }
        public static Printer Error { get; set; }
        public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new System.Text.UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, System.Text.Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, IEnumerable<T> source) { Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(System.IO.Stream stream) { iStream = stream; }
        private readonly System.IO.Stream iStream;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        private bool eof = false;
        public bool IsEndOfStream { get { return eof; } }
        const byte lb = 33, ub = 126, el = 10, cr = 13;
        public byte read()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            if (ptr >= len) { ptr = 0; if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while (b < lb || ub < b);            return (char)b; }
        public char[] Char(int n) { var a = new char[n]; for (int i = 0; i < n; i++) a[i] = Char(); return a; }
        public char[][] Char(int n, int m) { var a = new char[n][]; for (int i = 0; i < n; i++) a[i] = Char(m); return a; }
        public string Scan()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            StringBuilder sb = null;
            var enc = System.Text.UTF8Encoding.Default;
            do
            {
                for (; ptr < len && (buf[ptr] < lb || ub < buf[ptr]); ptr++) ;
                if (ptr < len) break;
                ptr = 0;
                if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return ""; }
            } while (true);
            do
            {
                var f = ptr;
                for (; ptr < len; ptr++)
                    if (buf[ptr] < lb || ub < buf[ptr])
                    //if (buf[ptr] == cr || buf[ptr] == el)
                    {
                        string s;
                        if (sb == null) s = enc.GetString(buf, f, ptr - f);
                        else { sb.Append(enc.GetChars(buf, f, ptr - f)); s = sb.ToString(); }
                        ptr++; return s;
                    }
                if (sb == null) sb = new StringBuilder(enc.GetString(buf, f, len - f));
                else sb.Append(enc.GetChars(buf, f, len - f));
                ptr = 0;

            }
            while (!eof && (len = iStream.Read(buf, 0, 1024)) > 0);
            eof = true; return (sb != null) ? sb.ToString() : "";
        }
        public long Long()
        {
            long ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public int Integer()
        {
            int ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public double Double() { return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture); }
        public string[] Scan(int n) { var a = new string[n]; for (int i = 0; i < n; i++) a[i] = Scan(); return a; }
        public double[] Double(int n) { var a = new double[n]; for (int i = 0; i < n; i++) a[i] = Double(); return a; }
        public int[] Integer(int n) { var a = new int[n]; for (int i = 0; i < n; i++) a[i] = Integer(); return a; }
        public long[] Long(int n) { var a = new long[n]; for (int i = 0; i < n; i++)a[i] = Long(); return a; }
        public void Flush() { iStream.Flush(); }
    }
}
#endregion
#region Extension
namespace Solver.Ex
{
    static public partial class EnumerableEx
    {
        static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
        static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    }
}
#endregion
#region BinarySearch for Array
static public partial class Algorithm
{

    static private int binarySearch<T>(this T[] a, int idx, int len, T v, Comparison<T> cmp, bool islb)
    {
        int l = idx;
        int h = idx + len - 1;
        while (l <= h)
        {
            int i = l + ((h - l) >> 1);
            int ord;
            if (a[i] == null || v == null) return -1;
            else ord = cmp(a[i], v);
            if (ord < 0) l = i + 1;
            else if (ord == 0)
            {
                if (!islb) l = i + 1;
                else h = i - 1;
            }
            else h = i - 1;
        }

        return l;
    }
    static public int UpperBound<T>(this T[] a, int idx, int len, T v, Comparison<T> cmp) { return binarySearch(a, idx, len, v, cmp, false); }
    static public int UpperBound<T>(this T[] a, int idx, int len, T v) where T : IComparable<T> { return UpperBound(a, idx, len, v, Comparer<T>.Default.Compare); }
    static public int UpperBound<T>(this T[] a, T v) where T : IComparable<T> { return UpperBound(a, 0, a.Length, v, Comparer<T>.Default.Compare); }
    static public int UpperBound<T>(this T[] a, T v, IComparer<T> cmp) { return UpperBound(a, 0, a.Length, v, cmp.Compare); }
    static public int UpperBound<T>(this T[] a, T v, Comparison<T> cmp) { return UpperBound(a, 0, a.Length, v, cmp); }

    static public int LowerBound<T>(this T[] a, int idx, int len, T value, Comparison<T> cmp) { return binarySearch(a, idx, len, value, cmp, true); }
    static public int LowerBound<T>(this T[] a, int idx, int len, T value) where T : IComparable<T> { return LowerBound(a, idx, len, value, Comparer<T>.Default.Compare); }
    static public int LowerBound<T>(this T[] a, T val) where T : IComparable<T> { return LowerBound(a, 0, a.Length, val, Comparer<T>.Default.Compare); }
    static public int LowerBound<T>(this T[] a, T val, IComparer<T> cmp) { return LowerBound(a, 0, a.Length, val, cmp.Compare); }
    static public int LowerBound<T>(this T[] a, T v, Comparison<T> cmp) { return LowerBound(a, 0, a.Length, v, cmp); }
}
#endregion

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Numerics;
namespace ConsoleApplication25
{
    class Solution
    {
        static void Main(string[] args)
        {
            var start = int.Parse(Console.ReadLine());

            var ans = 0;

            for (int i = 1; i <= 16; i++)
            {
                if ((start + i).ToString().Contains('8'))
                {
                    Console.WriteLine(i);
                    return;
                }
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication33
{
    class Program
    {
        static void Main(string[] args)
        {
            long input = Int64.Parse(Console.ReadLine());
            string chislo = Convert.ToString(input);
            long count = 0;
            Boolean isFind = false;
            do
            {
                input++;
                count++;
                chislo = Convert.ToString(input);
                for (int i = 0; i < chislo.Length; i++)
                {
                    if (chislo[i] == '8') { isFind = true; break; }
                }
            } while (isFind != true);
            Console.WriteLine(count);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication33
{
    class Program
    {
        static void Main(string[] args)
        {
            long input = Int64.Parse(Console.ReadLine());
            string chislo = Convert.ToString(input);
            long c = 0;
            Boolean isFind = false;
            do
            {
                input++;
                c++;
                chislo = Convert.ToString(input);
                for (int i = 0; i < chislo.Length; i++)
                {
                    if (chislo[i] == '8') { isFind = true; break; }
                }
            } while (isFind != true);
            Console.WriteLine(c);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForcesTest.Round278
{
    class GigaTower
    {
        public static void Main(string[] args)
        {
            Run();
            Console.ReadLine();
        }

        static void Run()
        {
            var input = Console.ReadLine();
            Int64 a = Convert.ToInt64(input);
            int res = 0;
            while (true)
            {
                res++;
                Int64 i = ++a;
                if (i.ToString().Contains('8'))
                {
                    Console.WriteLine(res);
                    return;
                }
            }
        }

    }
}

using System;

class A488 {
    public static void Main() {
        var n = int.Parse(Console.ReadLine());
        var m = n + 1;
        while (m.ToString().IndexOf('8') == -1) ++m;
        Console.WriteLine(m - n);
    }
}

using System;

namespace R_A_278
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            long a = long.Parse(s) + 1, b=1;
            s = a.ToString();
            bool c = false;
            while(!(c))
            {
                c = false;
                for (int i = 0; i < s.Length; i++)
                {
                    if (s[i] == '8')
                    {
                        c = true;
                        break;
                    }
                }
                if (!(c))
                {
                    b++;
                    a++;
                    s = a.ToString();
                }
            }
            Console.WriteLine(b);
        }
    }
}

using System;

namespace sertree
{
    class Program
    {
        public static void Main(string[] args)
        {
            int f = int.Parse(Console.ReadLine());

            for (int i = f+1; i < f+1100; i++) {
                if(i.ToString().Contains("8"))
                {
                    Console.Write(i-f);
                    break;
                }
            }

//
//          Console.Write("Press any key to continue . . . ");
//          Console.ReadKey(true);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _278_Task_A
{
    class Program
    {
        static void Main(string[] args)
        {
            long a = long.Parse(Console.ReadLine());
            string arr = Convert.ToString(a);
            int count = 0;
            Boolean check = false;
            do
            {
                a++;
                count++;
                arr = Convert.ToString(a);
                for (int i = 0; i < arr.Length; i++)
                {
                    if (arr[i] == '8') { check = true; break; }
                }
            } while (check != true);
            Console.WriteLine(count);
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Giga_Tower
{
    class Program
    {
        static void Main(string[] args)
        {
            int num_A = int.Parse(Console.ReadLine()) + 1;
            int num_B = 1;
            while (!num_A.ToString().Contains("8"))
            {
                num_B++;
                num_A++;
            }
            Console.WriteLine(num_B);
        }
    }
}

using System;
using System.IO;
using System.Text;

namespace Giga_Tower
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int a = Next();
            int c = 0;
            do
            {
                a++;
                c++;
            } while (!a.ToString().Contains("8"));

            writer.WriteLine(c);
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            int m = 1;
            do
            {
                c = reader.Read();
                if (c == '-')
                    m = -1;
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return m*res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

using System;

public class Test
{
	public static int Main()
	{
	  long a=long.Parse(Console.ReadLine());

	  int count=0;
	  while(true)
	  {
	  	a++;
	  	count++;
	  	if(ce(a))
	  	{
	  		Console.WriteLine(count);
	  		return 0;

	  	}

	  }

	  }

	public static bool ce(long a)
	{
		string s=a.ToString();
		int flag=0;
		for(int i=0;i<s.Length;i++)
		{
			if(s[i]=='8')
				flag=1;
		}
		if(flag==1)
		return true;
		else
		return false;
	}
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(File.OpenText("in.txt"));
            var n = long.Parse(Console.ReadLine());
            for (int i = 1; i < 20; i++)
            {
                var res = check(n + i);
                if (res)
                {
                    Console.WriteLine(i);
                    return;
                }
            }

        }

        static bool check(long n)
        {
            long temp = n;

            while (true)
            {
                var last = Math.Abs(temp % 10);
                temp = temp / 10;
                if (last == 8)
                {
                    return true;
                }

                if (temp == 0)
                {
                    return false;
                }
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CF_278_A {
public class Program {
    public static long et;
    public static long a;
    public static long b;

    public static void Main(string[] args) {

      string[] str = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
      a = long.Parse(str[0]);

      long res = Func1();

      Console.WriteLine(res);
      Console.ReadLine();
    }

    public static long Func1(){
      long res = 1;

      res = a;
      while (true) {
        res++;
        if (res.ToString().Contains('8')) break;
      }

      return res - a;
    }
  }
}

using System;

public class Test
{
    public static void Main()
    {
        // your code goes here
        long n = long.Parse(Console.ReadLine());
        long counter = 0 ;
        while(true){
            n++;
            counter++;
            //Console.WriteLine(n);
            if(Is8(n))
                break;
        }
        Console.WriteLine(counter);
    }

    static bool Is8(long number){
        if(number.ToString().Contains("8"))
             return true;
        return false;
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HelloWorld
{
    class Test
    {
        static int n, c, l;

        public static void Main()
        {
          /*  MyStack stack = new MyStack(5);

            for (int j = 0; j < 5; j++)
            {
                stack.push(j);
            }

            Console.WriteLine(stack.isFull());
            Console.WriteLine(stack.getNumberOfElements());
            while (!stack.isEmpty())
            {
                Console.WriteLine(stack.pop());

            }

            Console.WriteLine(stack.isEmpty());
            Console.WriteLine(stack.getNumberOfElements());
            Console.WriteLine(stack.getSize());

            Program pr = new Program("Sanan", 19);
            Console.WriteLine("before change " + pr.getName());
            Program p = Program.change(pr);
            Console.WriteLine("after change " + pr.getName());
            Console.WriteLine(p);

            int a = 5;

            sqr(ref a);

           Console.WriteLine(a);

           int x  =9; int y =6;
           swap(ref x, ref y);

           Console.WriteLine("x = " + x + " y = " + y);

           double d = 10.1325;
           double ost;

           int  whole =  splitNumber(d, out ost);

           Console.WriteLine("Целая часть " + whole + "\n" + "Дробная часть " + ost);*/

            n = Convert.ToInt32(Console.ReadLine());
            l = n;
            n++;
            while (true)
            {
                if (luckyNumber(n))
                {
                    c = n;
                    break;
                }
                else n++;
              }

            Console.WriteLine(Math.Abs(l - n));

           //Console.ReadKey();
        }
        static bool luckyNumber(int n)
        {
            String S = n.ToString();
            return S.Contains("8");
        }

        static void sqr( ref int a)
        {
            a = a * a;
        }

        static void swap(ref int a, ref int b) {

            int temp = a;
            a = b;
            b = temp;

        }

        static int splitNumber(double d, out double ost)
        {
            int n = (int)d;
            ost = d - n;

            return n;
        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.IO;
using System.Numerics;
using System.Globalization;
using System.Threading;

namespace probleme {
    class Program {
        static bool lucky(int n) {
            if (n < 0) {
                n = -n;
            }
            bool ans = false;
            while (n > 0) {
                if (n % 10 == 8) {
                    ans = true;
                    break;
                }
                n /= 10;
            }
            return ans;
        }
        static void Main(string[] args) {
            //Console.SetIn(new StreamReader("file.txt"));
            int n = int.Parse(Console.ReadLine());
            int b = 1;
            while (true) {
                if (lucky(n + b)) {
                    break;
                }
                b++;
            }
            Console.Write(b);
            //Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication33
{
    class Program
    {
        static void Main(string[] args)
        {
            long b = Int64.Parse(Console.ReadLine());
            string r = Convert.ToString(b);
            int count = 0;
            Boolean isTrue = false;
            do
            {
                b++;
                count++;
                r = Convert.ToString(b);
                for (int i = 0; i < r.Length; i++)
                {
                    if (r[i] == '8') { isTrue = true; break; }
                }
            } while (isTrue != true);
            Console.WriteLine(count);
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CF_GigaTower
{
    class Program
    {
        static void Main(string[] args)
        {
            long t = long.Parse(Console.ReadLine());
            t = t + 1;
            int count = 1;
            while(!t.ToString().Contains('8'))
            {
                t++;
                count++;
            }
            Console.WriteLine(count);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Task_TD
{

    class Program
    {

        public const int Diff = 20;

        static void Main(string[] args)
        {

            long a = Int64.Parse(Console.ReadLine());

            Console.WriteLine(GetResult(a));

            Console.ReadLine();
        }

        static long GetResult(long a)
        {
            long high = a + Diff;
            for (long i = a + 1; i < high; i++)
            {
                if (ContainsEight(i))
                    return i - a;
            }

            return -1;
        }

        static bool ContainsEight(long number)
        {
            if (number < 0)
                number = -number;

            while (number > 0)
            {
                if (number % 10 == 8)
                    return true;

                number = number / 10;
            }

            return false;
        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication33
{
 class Program
 {
 static void Main(string[] args)
 {
 long a = Int64.Parse(Console.ReadLine());
 string chislo = Convert.ToString(a);
 int count = 0;
 Boolean isTrue = false;
 do
 {
 a++;
 count++;
 chislo = Convert.ToString(a);
 for (int i = 0; i < chislo.Length; i++)
 {
 if (chislo[i] == '8') { isTrue = true; break; }
 }
 } while (isTrue != true);
 Console.WriteLine(count);
 Console.ReadLine();
 }
 }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _2016_08_23_giga_tower
{
    class Program
    {
        static void Main(string[] args)
        {
            //http://codeforces.com/contest/488/problem/A

            int floor = Convert.ToInt32(Console.ReadLine());

            int steps = 0;
            bool containsEight = false;

            while (containsEight == false)
            {
                floor++;
                steps++;
                containsEight = floor.ToString().Contains("8");
            }

            Console.WriteLine(steps);

        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
using System.Numerics;
using System.Threading;
using System.Diagnostics;

namespace StudyCSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            long stage, result = 0;
            byte[] Astage = {0};
            string buf;
            bool found = false;
            stage = Convert.ToInt32(Console.ReadLine());
            while (found == false)
            {
                stage++;
                result++;
                buf = stage.ToString();
                Astage = ArrCharToArrByte(buf, Astage);
                for (int i = 0; i < Astage.Length; i++)
                    if (Astage[i]==8)
                    {
                        found = true;
                        break;
                    }
            }
            Console.WriteLine(result);
        }

        static byte[] ArrCharToArrByte(string buf, byte[] stage)
        {
            stage = new byte[buf.Length];
            for (int i = 0; i < buf.Length; i++)
                Byte.TryParse(buf[i].ToString(), out stage[i]);
            return stage;
        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
using System.Numerics;
using System.Threading;
using System.Diagnostics;

namespace StudyCSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            long stage, result = 0;
            byte[] Astage = {0};
            string buf;
            bool found = false;
            stage = Convert.ToInt32(Console.ReadLine());
            while (found == false && result <= 20)
            {
                stage++;
                result++;
                buf = stage.ToString();
                Astage = ArrCharToArrByte(buf, Astage);
                for (int i = 0; i < Astage.Length; i++)
                    if (Astage[i]==8)
                    {
                        found = true;
                        break;
                    }
            }
            Console.WriteLine(result);
        }

        static byte[] ArrCharToArrByte(string buf, byte[] stage)
        {
            stage = new byte[buf.Length];
            for (int i = 0; i < buf.Length; i++)
                Byte.TryParse(buf[i].ToString(), out stage[i]);
            return stage;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bashnya
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            Int64 k = Int64.Parse(Console.ReadLine());
            int n = 0;
            bool p = false;
            for (; ; )
            {
                p = false;
                s = k.ToString();
                for (int i = 0; i < s.Length; i++)
                    if (s[i] == '8')
                        p = true;
                if ((p)&&(n>0))
                    break;
                k++;
                n++;
            }
            Console.WriteLine(n.ToString());

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace zero_and_one
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());

            for (long i = 1; i < 100000000; i++)
            {
                n++;
                string s = n.ToString();
                if (s.Contains('8'))
                {
                    Console.WriteLine(i);
                    break;
                }
            }

        }
    }
}

using System;

class Program
{
    static void Main(string[] args)
    {
        int a = int.Parse(Console.ReadLine());
        int b = a + 1;
        while (!b.ToString().Contains("8")) b++;
        Console.WriteLine(b - a);
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication37
{
    class Program
    {
        static void Main(string[] args)
        {
            long number = long.Parse(Console.ReadLine());
            long i = 0;
            if (number.ToString().Contains('8'))
            {
                number++;
                i = 1;
            }
            while (!number.ToString().Contains('8'))
            {
                i++;
                number++;

            }

            Console.WriteLine(i);
            Console.Read();
        }
    }
}

using System;
using System.Collections.Generic;
using System.IO;

namespace prA {

    class Program {
#if ONLINE_JUDGE
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
#else
        private static readonly StreamWriter writer = new StreamWriter("output");
        private static readonly StreamReader reader = new StreamReader("input");
#endif
        static void Main(string[] args) {
            long a = Next();
            int d = 1;
            while((a + d).ToString().IndexOf('8') == -1) {
                d++;
            }
            writer.Write(d);

            writer.Flush();
#if !ONLINE_JUDGE
            writer.Close();
#endif
        }
        private static long Next() {
            long c;
            long res = 0;
            do {
                c = reader.Read();
                if(c == -1)
                    return res;
            } while(c != '-' && (c < '0' || c > '9'));
            long sign = 1;
            if(c == '-') {
                sign = -1;
                c = reader.Read();
            }
            res = c - '0';
            while(true) {
                c = reader.Read();
                if(c < '0' || c > '9')
                    return res * sign;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public object Solve()
    {
        int a = ReadInt();
        int b = a + 1;
        while (!b.ToString().Contains("8"))
            b++;
        return b - a;

        return null;
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;

    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("instruction.in");
        //writer = new StreamWriter("instruction.out");
#endif
        try
        {
            object result = new Solver().Solve();
            if (result != null)
                writer.WriteLine(result);
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            Console.WriteLine(ex);
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write

    private static Queue<string> currentLineTokens = new Queue<string>();

    private static string[] ReadAndSplitLine()
    {
        return reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public static string ReadToken()
    {
        while (currentLineTokens.Count == 0)
            currentLineTokens = new Queue<string>(ReadAndSplitLine());
        return currentLineTokens.Dequeue();
    }

    public static int ReadInt()
    {
        return int.Parse(ReadToken());
    }

    public static long ReadLong()
    {
        return long.Parse(ReadToken());
    }

    public static double ReadDouble()
    {
        return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
    }

    public static int[] ReadIntArray()
    {
        return ReadAndSplitLine().Select(int.Parse).ToArray();
    }

    public static long[] ReadLongArray()
    {
        return ReadAndSplitLine().Select(long.Parse).ToArray();
    }

    public static double[] ReadDoubleArray()
    {
        return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
    }

    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }

    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows);
        int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = new int[numberOfRows];
            for (int j = 0; j < numberOfRows; j++)
                ret[i][j] = matrix[j][i];
        }
        return ret;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
            lines[i] = reader.ReadLine().Trim();
        return lines;
    }

    public static void WriteArray<T>(IEnumerable<T> array)
    {
        writer.WriteLine(string.Join(" ", array));
    }

    public static void Write<T>(params T[] array)
    {
        WriteArray(array);
    }

    public static void WriteLines<T>(IEnumerable<T> array)
    {
        foreach (var a in array)
            writer.WriteLine(a);
    }

    #endregion
}

using System;
using System.Collections.Generic;
using System.Text;

class PairVariable : IComparable<PairVariable>
{
    public int a, b;
    public PairVariable()
    {

    }

    public PairVariable(string s)
    {
        string[] q = s.Split();
        a = int.Parse(q[0]);
        b = int.Parse(q[1]);
    }
    public PairVariable(int a, int b)
    {
        this.a = a;
        this.b = b;
    }
    public int CompareTo(PairVariable pv)
    {
        if (this.a > pv.a)
        {
            return 1;
        }
        else if (this.a < pv.a)
        {
            return -1;
        }
        else
        {
            if (this.b >= pv.b)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
    }

}
namespace ConsoleApplication1
{
    class Program
    {

        static bool f(int n)
        {

            string s = n.ToString();
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == '8')
                {
                    return true;
                }
            }
            return false;
        }

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            n++;
            int k = 1;
            while (true)
            {
                if (f(n))
                {
                    Console.WriteLine(k);
                    return;
                }
                n++;
                k++;
            }
        }
    }
}

using System;
using System.Linq;

namespace tren
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            long[] mass = new long[17];
            for(int i = 0; i < 17; i++)
            {
                mass[i] = n + i;
            }
            for(int i = 1; i < mass.Count(); i++)
            {
                if (mass[i].ToString().Contains('8')) { Console.Write(i); return; }
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication20
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            n++;

            string tmp;
            int counter = 0;
            char[] res;
            bool act = false;

            while (act != true)
            {
                tmp = n.ToString();
                res = tmp.ToCharArray();

                for (int i = 0; i < res.Length; i++)
                {
                    if (res[i] == '8')
                    {
                        act = true;
                        break;
                    }
                }
                n++;
                counter++;
            }
            Console.WriteLine(counter);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace ConsoleApplication1
{
    class Program
    {
        static bool check(long a)
        {
            if (a > 0)
            {
                while (a > 0)
                {
                    if (a % 10 == 8)
                        return true;
                    a /= 10;
                }
                return false;
            }
            else
            {
                while (a < 0)
                {
                    if (a % 10 == -8)
                        return true;
                    a /= 10;
                }
                return false;
            }
        }
        static void Main(string[] args)
        {
            long line = long.Parse(Console.ReadLine());
            long count=0;
            while (true)
            {
                line++;
                count++;
                if (check(line))
                {
                    Console.WriteLine(count);
                    break;
                }
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = Int32.Parse(Console.ReadLine());
            int n = 1000000000 * 2;
            for (int i = 1; i<=n; i++){
                if ((a + i).ToString().Contains("8"))
                {
                    Console.WriteLine(i);
                    break;
                }
            }
            //for(int i=0;i<)
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            long a = Convert.ToInt64(Console.ReadLine());
            string level;
            int counter = 0;
            Boolean Luck = false;
            while (Luck == false)
            {
                a++;
                counter++;
                level = Convert.ToString(a);
                for (int i = 0; i < level.Length; i++)
                {
                    if (level[i] == '8')
                    { Luck = true; }
                }
            }
            Console.WriteLine(counter);
        }
    }
}

using System;

    class MainClass
    {
        public static void Main(string[] args)
        {
            int res = 0;
            string s = Console.ReadLine ();
            do
            {
                res++;
                s = (Int64.Parse (s) + 1).ToString ();
            } while(s.IndexOf ("8") == -1) ;
            Console.WriteLine (res);
        }
    }

using System;
class Program
{
    static bool isLucky(long n)
    {
        while (n != 0)
        {
            if (Math.Abs(n % 10) == 8)
            {
                return true;
            }
            n /= 10;
        }
        return false;
    }
    static void Main()
    {
        long b = 0;
        var a = long.Parse(Console.ReadLine());
        a++;
        b++;
        while (!isLucky(a))
        {
            a++;
            b++;
        }
        Console.WriteLine(b);
    }
}

using System;
namespace CodeForces
{
    public class A
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            long n = Convert.ToInt64(s);
            n++;
            int ans = 1;
            while ((n+"").IndexOf('8') == -1)
            {
                n++;
                ans++;
            }
            Console.WriteLine(ans);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());

            for (long i = 1; i < 100000000; i++)
            {
                n++;
                string s = n.ToString();
                if (s.Contains('8'))
                {
                    Console.WriteLine(i);
                    break;
                }
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces284
{
    class Program
    {
        static void Main(string[] args)
        {
            /*ulong n;
            ulong m;
            ulong b;
            string s = Console.ReadLine();
            char[] ch = s.ToCharArray();
            if (ch[0] == '-')
            {
                n = ulong.Parse(s);
                b = n;
                char[] bc = b.ToString().ToCharArray();
                while (bc[bc.Length - 1] != 8)
                {
                    b++;
                    bc = b.ToString().ToCharArray();
                }
            }
            else
            {
                m = ulong.Parse(s);
                b = m;
                char[] bc = b.ToString().ToCharArray();
                while ((bc[bc.Length - 1] != 8)||(bc[0]=='-'))
                {
                    b++;
                    bc = b.ToString().ToCharArray();
                }
            }
            Console.WriteLine(b);*/
            long n = long.Parse(Console.ReadLine());
            int k = 0;
            bool flag = true;
                char[] ch = n.ToString().ToCharArray();
                while (flag)
                {
                    n++;
                    k++;
                    ch = n.ToString().ToCharArray();
                    for (int i = 0; i < ch.Length; i++)
                    {
                        if (ch[i] == '8')
                            flag = false;
                    }

                }
                Console.WriteLine(k);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace a2oj
{
    class Program
    {
        static bool cheight(int num)
        {
            while(num>0)
            {
                if (num % 10 != 8)
                    num /= 10;
                else
                    return true;
            }
            return false;
        }

        static void Main(string[] args)
        {
            int n;
            int t;
            n = int.Parse(Console.ReadLine());
            t=n;
            //List<int> val = new List<int>();
            //string s= Console.ReadLine();
            //string []all=s.Split(' ');
            //foreach(string st in all)
            //{
            //    val.Add(int.Parse(st));
            //}
            if(n>-9)
            {
                n++;
                while (!cheight(n))
                    n++;
                Console.WriteLine(n - t);
            }
            else
            {
                n = Math.Abs(n);
                n--;
                while (!cheight(n))
                    n--;
                Console.WriteLine(-n - t);
            }

            //Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;

namespace codeforces
{
	class Program
	{
		public class User
		{
			public int c;

			public int r;
		}

		public class Comparer : IComparer<User>
		{
			public int Compare(User x, User y)
			{
				if (x.c < y.c || (x.c == y.c && x.r < y.r))
					return -1;
				return 1;
			}
		}

		public static long getGcd(long a, long b)
		{
			if (b == 0)
				return a;
			return getGcd(b, a % b);
		}

		public static void WriteYESNO(bool x, string yes = "YES", string no = "NO")
		{
			if (x)
				Console.WriteLine(yes);
			else
			{
				Console.WriteLine(no);
			}
		}

		public static string GetString()
		{
			return Console.ReadLine();
		}

		public static List<int> getList()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(int.Parse).ToList();
		}

		public static int Min(int x, int y)
		{
			return Math.Min(x, y);
		}

		public static int Max(int x, int y)
		{
			return Math.Max(x, y);
		}

		public static int Abs(int x)
		{
			return Math.Abs(x);
		}

		public static int getInt()
		{
			var s = Console.ReadLine();
			return int.Parse(s);
		}

		public static bool Equal(int x, int y, int x1, int y1)
		{
			return x == x1 && y == y1;
		}

		public class Vertex
		{
			public List<int> edges;

			public int ct;

			public Vertex()
			{
				ct = 0;
				edges = new List<int>();
				for (var i = 0; i < 26; ++i)
					edges.Add(0);
			}
		}

		private static void Main(string[] args)
		{
/*			var input = new StreamReader("input.txt");
			var output = new StreamWriter("output.txt");*/
			var n = getInt();
			var ans = 0;
			while (true)
			{
				ans++;
				n++;
				var q = Abs(n);
				while (q != 0)
				{
					if (q % 10 == 8)
					{
						Console.WriteLine(ans);
						return;
					}
					q /= 10;
				}
			}
			/*			input.Close();
			output.Close();*/
		}
	}
}

using System;

namespace CFSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            long a = long.Parse(Console.ReadLine()) + 1;
            long c = 1;
            while (!(a.ToString().Contains("8"))){ a++; c++; }
            Console.Write(c);
        }

    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace Giga_tower
{
    class Program
    {
        static void Main(string[] args)
        {
            var inicio = int.Parse(Console.ReadLine());

            for (int i = 0; i <=16 ; i++)
            {
                if ((inicio + i).ToString().Contains('8') && i!=0)
                {
                    Console.WriteLine(i);
                    return;
                }
            }

            Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.Remoting.Services;
using System.Text;
using System.Xml.Linq;

#region ioh

class Scanner
{
    private readonly TextReader reader;
    private string[] buffer;
    private int bufferPos;

    public Scanner()
        : this(null)
    { }

    public Scanner(TextReader reader)
    {
        this.reader = reader ?? Console.In;
        buffer = new string[0];
    }

    public string NextTerm()
    {
        if (bufferPos >= buffer.Length)
        {
            buffer = reader.ReadLine().Split(' ');
            bufferPos = 0;
        }

        return buffer[bufferPos++];
    }

    public int NextInt()
    {
        return int.Parse(NextTerm());
    }

    public int[] NextIntArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    }

    public int[][] NextIntMatrix(int rowCount)
    {
        var matrix = new int[rowCount][];

        for (int i = 0; i < matrix.Length; i++)
        {
            matrix[i] = NextIntArray();
        }

        return matrix;
    }
}

#endregion

class Program
{
    private static readonly Scanner s = new Scanner();

    private static void Main(string[] args)
    {
        var s = int.Parse(Console.ReadLine());

        if (s < 0)
        {
            Console.WriteLine(Math.Abs(s)+8);
        }
        else
        {
            var a = 0;

            while (true)
            {
                a++;
                s++;
                if (s.ToString().Contains('8')) break;
            }

            Console.WriteLine(a);
        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace Giga_tower
{
    class Program
    {
        static void Main(string[] args)
        {
            var inicio = Convert.ToInt32(Console.ReadLine());

            for (int i = 0; i <=16 ; i++)
            {
                if ((inicio + i).ToString().Contains('8'))
                {
                    Console.WriteLine(i);
                    return;
                }
            }
            Console.ReadKey();
        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace Giga_tower
{
    class Program
    {
        static void Main(string[] args)
        {
            var inicio = Convert.ToInt32(Console.ReadLine());
            var auxiliar = 0;

            for (int i = 0; i <=16 ; i++)
            {
                if ((inicio + i).ToString().Contains('8'))
                {
                    Console.WriteLine(i);
                    return;
                }
            }
            Console.ReadKey();
        }
    }
}

// A Dynamic Programming based
// C# program to find minimum
// number operations to
// convert str1 to str2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Lap
{
    public int P;
    public int Q;

}
class GFG
{
    static string[] memo = new string[13];

    public static void Main()
    {
        bool check = false;
        var n = int.Parse(Console.ReadLine());
        int count = 0;

        count = 0;
        for (int i = n; i <= 1000000000; i++)
        {

            int num = i;
            while (num > 0 && i > n)
            {
                var digit = num % 10;
                if (digit == 8)
                {
                    check = true;
                    break;
                }
                num = num / 10;
            }

            if (check)
                break;
            count++;

        }
        Console.Write(count);
        return;

    }

}

// A Dynamic Programming based
// C# program to find minimum
// number operations to
// convert str1 to str2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Lap
{
    public int P;
    public int Q;

}
class GFG
{
    static string[] memo = new string[13];

    public static void Main()
    {
        bool check = false;
        var n = Math.Abs(int.Parse(Console.ReadLine()));
        int count = 0;

        count = 0;
        for (int i = n; i <= 1000000000; i++)
        {

            int num = i;
            while (num > 0 && i > n)
            {
                var digit = num % 10;
                if (digit == 8)
                {
                    check = true;
                    break;
                }
                num = num / 10;
            }

            if (check)
                break;
            count++;

        }
        Console.Write(count);
        return;

    }

}

// A Dynamic Programming based
// C# program to find minimum
// number operations to
// convert str1 to str2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Lap
{
    public int P;
    public int Q;

}
class GFG
{
    static string[] memo = new string[13];

    public static void Main()
    {
        bool check = false;
        var n = int.Parse(Console.ReadLine());
        int count = 1;
        if (n < 0)
        {
            for (int i = n; i <= 1000000000; i--)
            {

                int num = i;
                while (num <0)
                {
                    var digit = num % 10;
                    if (digit == -8)
                    {
                        check = true;
                        break;
                    }
                    num = num / 10;
                }
                count++;
                if (check)
                    break;

            }
            Console.Write(count);
            return;
        }
        if (n > 0)
        {
            for (int i = n; i <= 1000000000; i++)
            {

                int num = i;
                while (num > 0)
                {
                    var digit = num % 10;
                    if (digit == 8)
                    {
                        check = true;
                        break;
                    }
                    num = num / 10;
                }
                count++;
                if (check)
                    break;

            }
            Console.Write(count);
            return;
        }
        Console.Write("-1");
    }

}

// A Dynamic Programming based
// C# program to find minimum
// number operations to
// convert str1 to str2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Lap
{
    public int P;
    public int Q;

}
class GFG
{
    static string[] memo = new string[13];

    public static void Main()
    {
        bool check = false;
        var n = int.Parse(Console.ReadLine());
        int count = 1;
        if (n < 0)
        {
            for (int i = n; i <= 1000000000; i--)
            {

                int num = i;
                while (num <0&&i<n)
                {
                    var digit = num % 10;
                    if (digit == -8)
                    {
                        check = true;
                        break;
                    }
                    num = num / 10;
                }
                count++;
                if (check)
                    break;

            }
            Console.Write(count);
            return;
        }
        if (n > 0)
        {
            count = 0;
            for (int i = n; i <= 1000000000; i++)
            {

                int num = i;
                while (num > 0&&i>n)
                {
                    var digit = num % 10;
                    if (digit == 8)
                    {
                        check = true;
                        break;
                    }
                    num = num / 10;
                }

                if (check)
                    break;
                count++;

            }
            Console.Write(count);
            return;
        }
        Console.Write("-1");
    }

}

// A Dynamic Programming based
// C# program to find minimum
// number operations to
// convert str1 to str2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Lap
{
    public int P;
    public int Q;

}
class GFG
{
    static string[] memo = new string[13];

    public static void Main()
    {
        bool check = false;
        var n = int.Parse(Console.ReadLine());
        int count = 0;

        count = 0;
        if (n < 0)
        {
            for (int i = n; i <= 1000000000; i++)
            {

                int num = Math.Abs(i);
                while (num > 0 && i > n)
                {
                    var digit = num % 10;
                    if (digit == 8)
                    {
                        check = true;
                        break;
                    }
                    num = num / 10;
                }

                if (check)
                    break;
                count++;

            }
        }
        if (n > 0)
        {
            for (int i = n; i <= i + 10; i++)
            {

                int num = i;
                while (num > 0 && i > n)
                {
                    var digit = num % 10;
                    if (digit == 8)
                    {
                        check = true;
                        break;
                    }
                    num = num / 10;
                }

                if (check)
                    break;
                count++;

            }
            Console.Write(count);
            return;
        }

    }

}

// A Dynamic Programming based
// C# program to find minimum
// number operations to
// convert str1 to str2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Lap
{
    public int P;
    public int Q;

}
class GFG
{
    static string[] memo = new string[13];

    public static void Main()
    {
        bool check = false;
        var n = int.Parse(Console.ReadLine());
        int count = 1;
        if (n < 0)
        {
            for (int i = n; i <= 1000000000; i--)
            {

                int num = i;
                while (num <0)
                {
                    var digit = num % 10;
                    if (digit == -8)
                    {
                        check = true;
                        break;
                    }
                    num = num / 10;
                }
                count++;
                if (check)
                    break;

            }
            Console.Write(count);
            return;
        }
        if (n > 0)
        {
            count = 0;
            for (int i = n; i <= 1000000000; i++)
            {

                int num = i;
                while (num > 0)
                {
                    var digit = num % 10;
                    if (digit == 8)
                    {
                        check = true;
                        break;
                    }
                    num = num / 10;
                }

                if (check)
                    break;
                count++;

            }
            Console.Write(count);
            return;
        }
        Console.Write("-1");
    }

}

// A Dynamic Programming based
// C# program to find minimum
// number operations to
// convert str1 to str2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Lap
{
    public int P;
    public int Q;

}
class GFG
{
    static string[] memo = new string[13];

    public static void Main()
    {
        bool check = false;
        var n = int.Parse(Console.ReadLine());
        int count = 0;

        count = 0;
        if (n < 0)
        {
            for (int i = n; i <= 1000000000; i++)
            {

                int num = Math.Abs(i);
                while (num > 0 && i > n)
                {
                    var digit = num % 10;
                    if (digit == 8)
                    {
                        check = true;
                        break;
                    }
                    num = num / 10;
                }

                if (check)
                    break;
                count++;

            }
            Console.Write(count);
            return;
        }
        if (n > 0)
        {
            for (int i = n; i <= i + 10; i++)
            {

                int num = i;
                while (num > 0 && i > n)
                {
                    var digit = num % 10;
                    if (digit == 8)
                    {
                        check = true;
                        break;
                    }
                    num = num / 10;
                }

                if (check)
                    break;
                count++;

            }
            Console.Write(count);
            return;
        }

    }

}

// A Dynamic Programming based
// C# program to find minimum
// number operations to
// convert str1 to str2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Lap
{
    public int P;
    public int Q;

}
class GFG
{
    static string[] memo = new string[13];

    public static void Main()
    {
        bool check = false;
        var n = int.Parse(Console.ReadLine());
        int count = 0;
        if (n < 0)
        {
            for (int i = n; i <= 1000000000; i--)
            {

                int num = i;
                while (num <0&&i<n)
                {
                    var digit = num % 10;
                    if (digit == -8)
                    {
                        check = true;
                        break;
                    }
                    num = num / 10;
                }

                if (check)
                    break;

                count++;

            }
            Console.Write(count);
            return;
        }
        if (n > 0)
        {
            count = 0;
            for (int i = n; i <= 1000000000; i++)
            {

                int num = i;
                while (num > 0&&i>n)
                {
                    var digit = num % 10;
                    if (digit == 8)
                    {
                        check = true;
                        break;
                    }
                    num = num / 10;
                }

                if (check)
                    break;
                count++;

            }
            Console.Write(count);
            return;
        }
        Console.Write("-1");
    }

}

using System;

public class Test
{
	public static void Main()
	{
		long n = Convert.ToInt64(Console.ReadLine());
		int b=0;
		bool vodsem = true;
		while (vodsem)
		{
			b++;
			long xex = b+n;
		      while (xex>0)
		      {
		      	if(xex%10==8) vodsem=false;
		      	xex/=10;
		      }
		}
		Console.WriteLine(b);
	}
}

/*
 * Created by SharpDevelop.
 * User: ������
 * Date: 02.02.2016
 * Time: 21-30
 *
 *

A. ���������
��������� � ����� ������� � �������� ������ � ����������. � ��� 17,777,777,777 ������,
��������������� �� -8,888,888m888 �� 8,888,888,888. � ���������, ����� ������� -1 � 1 ���� ���� 0.
������ �������� ��������� �������� ����, ����� ����������� �������� �����.
� ���������� �����, ��� ����� �8� ������� ����� (������ ������� � ��������� 8,888,888,888 ������ ��� ������),
� ����� ����� �������� ���������� ����� � ������ �����, ����� � ��� ���������� ������ ���������� �� ������� ���� ���� ����� �8�.
��������, 8, -180, 808 � ������� ���������� �����, � 42, -10 � ���.
����� �� ������ ��� �� ����� �� ���������� �������, � ���� �������� ����� (�� � ���� ����� #278 ���� ����������, �� ��� ��?).
������ ����� ������ � ����� �� ������. ������ �� ��������� �� ����� ��� ������� a.
�� ����� ����� ����������� ������������� ����� ����� b, �����, ��� ���� �� ���������� �� b ������ �����,
�� �������� �� ����� �� ���������� �������.
������� ������
� ������������ ������ �������� ����� ����� a (-10^9 <= a <= 10^9).
�������� ������
�������� ����������� b.
������� ������
������� ������
179
�������� ������
1
������� ������
-1
�������� ������
9
������� ������
18
�������� ������
10
����������
� ������ ������� ����� ����� ����� �� ����� ����� 180.
�� ������ ������� � �� 8.
�������� ��������, ��� b ������ ���� ������������� ������, ��� ��� ����� � ������� ������� � 10, � �� 0.

 */

using System;

class Program
{
	public static void Main(string[] args)
	{
		int n = int.Parse (Console.ReadLine ());
		int nn = n;

		for ( n++; ; n++ )
		{
			int m = n;
			bool ok = false;
			while ( m > 0 )
			{
				if ( m % 10 == 8 )
				{
					ok = true;
					break;
				}
				m /= 10;
			}
			if ( ok )
				break;
		}

		Console.WriteLine (n - nn);
//		Console.ReadKey (true);
	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            long input = Int64.Parse(Console.ReadLine());
            long res = 0;
            if(input < 0)
            {
                res += Int64.Parse(input.ToString().Replace("-", ""));
                input += res;
            }
            for(long i = input+1; i <= 8888888888; i++)
            {
                if (i.ToString().Contains("8"))
                {
                    res += i-input;
                    break;
                }
            }
            Console.WriteLine(res);
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Team_BruteForce_
{
    class Program
    {
        static void Main(string[] args)
        {
            int andar = int.Parse( Console.ReadLine() );
            int NiveisSubidos = Operacao.VerificaNumero(andar, 0);
            Console.WriteLine(NiveisSubidos);
         }

    }

    static class Operacao
    {
        public static int VerificaNumero(int a, int contador)
        {

            string compara = Convert.ToString(a);
            if (compara.Contains("8"))
            {
                return contador;
            }
            else
            {
                contador++;
                return VerificaNumero(a + 1, contador);
            }

        }
    }

}

using System;
class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();//Console.In.ReadToEnd().Split(new char[] { '\n', '\r'}, StringSplitOptions.RemoveEmptyEntries);
            if (input[0] == '-')
            {
                if (input.Length == 2 && input[1] != '9')
                    Console.WriteLine((input[1] - 40));
                else
                {
                    int a = input.IndexOf('8');
                    if(a>=0)
                    {
                        if (a == input.Length - 1)
                        {
                            a = input.LastIndexOf('9');
                            if (a == -1) Console.WriteLine("10");
                            else
                            {
                                for (int i = a + 1, lim = input.Length - 1; i < lim; ++i)
                                    if (input[i] != '0') a = -1;
                                Console.WriteLine(a >= 0 ? "9" : "10");
                            }
                        }
                        else
                        {
                            for (int i = a + 1; i < input.Length; ++i)
                            {
                                if (input[i] != '0') { a = -1; break; }
                            }
                            Console.WriteLine(a >= 0 ? '2' : '1');
                        }
                    }
                    else
                    {
                        a = input.LastIndexOf('9');
                        if (a < 0) Console.WriteLine(input[input.Length - 1]-46);
                        else
                        {
                            if (input.Length - 1 == a) Console.WriteLine('1');
                            else
                            {
                                for (int i = a + 1; i < input.Length; ++i)
                                {
                                    if (input[i] != '0') { a = -1; break; }
                                }
                                Console.WriteLine(a >= 0 || a ==input.Length-1? "1" : (input[input.Length - 1] - 46).ToString());
                            }
                        }
                    }
                }
            }
            else
            {
                int a = input.IndexOf('8');
                if(a>=0)
                {
                    if(a==input.Length-1)
                    {
                        a = input.LastIndexOf('7');
                        if (a == -1) Console.WriteLine("10");
                        else
                        {
                            for (int i = a + 1, lim = input.Length - 1; i < lim; ++i)
                                if (input[i] != '9') a = -1;
                            Console.WriteLine(a >= 0 ? "2" : "10");
                        }
                    }
                    else
                    {
                        for (int i = a + 1; i < input.Length; ++i)
                        {
                            if (input[i] != '9') { a = -1; break; }
                        }
                        Console.WriteLine(a >= 0 ?'9':'1');
                    }
                }
                else
                {
                    a = input.LastIndexOf('7');
                    if (a < 0) Console.WriteLine(input[input.Length - 1] == '9' ? 9 : 56 - input[input.Length - 1]);
                    else
                    {
                        for (int i = a + 1; i < input.Length; ++i)
                        {
                            if (input[i] != '9') { a = -1; break; }
                        }
                        Console.WriteLine(a >= 0 ? "1" : (56-input[input.Length-1]).ToString());
                    }
                }
            }
        }
    }

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _488A
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = 0;
            n = Convert.ToInt64(Console.ReadLine());
            long m = n / 10;
            while (m!=0)
            {
                int temp;
                temp = (int)m % 10;
                m = m / 10;
                if (Math.Abs(temp)==8)
                {
                    Console.WriteLine("1");
                    return;
                }
            }
            if (n==0)
            {
                Console.WriteLine("8");
            }
            else
            {
                int t = (int)n % 10;
                if (t == 8)
                {
                    Console.WriteLine("10"); ;
                }
                else if (t == 0)
                {
                    Console.WriteLine("2");
                }
                else
                {
                    Console.WriteLine(Math.Abs(t - 8));
                }
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _488A
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = 0;
            n = Convert.ToInt64(Console.ReadLine());
            long m = n / 10;
            while (m!=0)
            {
                int temp;
                temp = (int)m % 10;
                m = m / 10;
                if (Math.Abs(temp)==8)
                {
                    Console.WriteLine("1");
                    return;
                }
            }
            if (n >= 0)
            {

                int t = (int)n % 10;
                if (t == 8)
                {
                    Console.WriteLine("10");
                }
                else
                {
                    Console.WriteLine(Math.Abs(t - 8));
                }
            }
            else
            {
                int t = (int)n % 10;
                if (t==-8)
                {
                    Console.WriteLine("10");
                }
                else if(t==0)
                {
                    Console.WriteLine("2");
                }
                else
                {
                    Console.WriteLine(Math.Abs(8-t));
                }
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _488A
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = 0;
            n = Convert.ToInt64(Console.ReadLine());
            long m = n / 10;
            while (m!=0)
            {
                int temp;
                temp = (int)m % 10;
                m = m / 10;
                if (Math.Abs(temp)==8)
                {
                    Console.WriteLine("1");
                    return;
                }
            }
            if (n >= 0)
            {

                int t = (int)n % 10;
                if (t == 8)
                {
                    Console.WriteLine("10");
                }
                else
                {
                    Console.WriteLine(Math.Abs(t - 8));
                }
            }
            else
            {
                if (n==-8)
                {
                    Console.WriteLine("16");
                    return;
                }
                int t = (int)n % 10;
                if (t==-8)
                {
                    Console.WriteLine("10");
                }
                else if(t==0)
                {
                    Console.WriteLine("2");
                }
                else
                {
                    Console.WriteLine(Math.Abs(8-t));
                }
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _488A
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = 0;
            n = Convert.ToInt64(Console.ReadLine());
            int temp;
            temp = (int)n % 10;
            if (temp==8)
            {
                Console.WriteLine("10"); ;
            }
            else
            {
                Console.WriteLine(Math.Abs(temp - 8));
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _488A
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = 0;
            n = Convert.ToInt64(Console.ReadLine());
            long m = n / 10;
            while (m!=0)
            {
                int temp;
                temp = (int)m % 10;
                m = m / 10;
                if (Math.Abs(temp)==8)
                {
                    Console.WriteLine("1");
                    return;
                }
            }
            if (n >= 0)
            {

                int t = (int)n % 10;
                if (t == 8)
                {
                    Console.WriteLine("10");
                }
                else
                {
                    Console.WriteLine(Math.Abs(t - 8));
                }
            }
            else
            {
                int t = (int)n % 10;
                if (t==-8)
                {
                    Console.WriteLine("10");
                }
                else if(t==0)
                {
                    Console.WriteLine("2");
                }
                else
                {
                    Console.WriteLine(Math.Abs(t+8));
                }
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _488A
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = 0;
            n = Convert.ToInt64(Console.ReadLine());
            long m = n / 10;
            while (m!=0)
            {
                int temp;
                temp = (int)m % 10;
                m = m / 10;
                if (Math.Abs(temp)==8)
                {
                    Console.WriteLine("1");
                    return;
                }
            }

                int t = (int)n % 10;
                if (t == 8)
                {
                    Console.WriteLine("10"); ;
                }
                else
                {
                    Console.WriteLine(Math.Abs(t - 8));
                }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _488A
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = 0;
            n = Convert.ToInt64(Console.ReadLine());
            long m = n / 10;
            while (m!=0)
            {
                int temp;
                temp = (int)m % 10;
                m = m / 10;
                if (Math.Abs(temp)==8)
                {
                    Console.WriteLine("1");
                    return;
                }
            }
            int t = (int)n % 10;
            if (t == 8)
            {
                Console.WriteLine("10"); ;
            }
            else
            {
                Console.WriteLine(Math.Abs(t - 8));
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _488A
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = 0;
            n = Convert.ToInt64(Console.ReadLine());
            long m = n / 10;
            while (m!=0)
            {
                int temp;
                temp = (int)m % 10;
                m = m / 10;
                if (Math.Abs(temp)==8)
                {
                    Console.WriteLine("1");
                    return;
                }
            }
            int t = (int)n % 10;
            if (t == 8)
            {
                Console.WriteLine("10"); ;
            }
            else if(t==0)
            {
                Console.WriteLine("2");
            }
            else
            {
                Console.WriteLine(Math.Abs(t - 8));
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _488A
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = 0;
            n = Convert.ToInt64(Console.ReadLine());
            long m = n / 10;
            while (m!=0)
            {
                int temp;
                temp = (int)m % 10;
                m = m / 10;
                if (Math.Abs(temp)==8)
                {
                    Console.WriteLine("1");
                    return;
                }
            }
            if (n >= 0)
            {

                int t = (int)n % 10;
                if (t == 8)
                {
                    Console.WriteLine("10");
                }
                else
                {
                    Console.WriteLine(Math.Abs(t - 8));
                }
            }
            else
            {
                if (n==-8)
                {
                    Console.WriteLine("16");
                }
                int t = (int)n % 10;
                if (t==-8)
                {
                    Console.WriteLine("10");
                }
                else if(t==0)
                {
                    Console.WriteLine("2");
                }
                else
                {
                    Console.WriteLine(Math.Abs(8-t));
                }
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _488A
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = 0;
            n = Convert.ToInt64(Console.ReadLine());
            if (n==0)
            {
                Console.WriteLine("8");
            }
            long m = n / 10;
            while (m!=0)
            {
                int temp;
                temp = (int)m % 10;
                m = m / 10;
                if (Math.Abs(temp)==8)
                {
                    Console.WriteLine("1");
                    return;
                }
            }
            int t = (int)n % 10;
            if (t == 8)
            {
                Console.WriteLine("10"); ;
            }
            else if(t==0)
            {
                Console.WriteLine("2");
            }
            else
            {
                Console.WriteLine(Math.Abs(t - 8));
            }

        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Numerics;
namespace ConsoleApplication25
{
    class Solution
    {
        static void Main(string[] args)
        {
            var start = Console.ReadLine();

            var ans = 0;
            if (start.Contains('8') && start.IndexOf('8') <= start.Length - 2)
            {
                Console.WriteLine(1);
                return;
            }
            if (int.Parse(start) == 0)
            {
                Console.WriteLine(8);
                return;
            }
            if (int.Parse(start) == 8)
            {
                Console.WriteLine(8);
                return;
            }

            if (int.Parse(start) > 0)
            {
                var l = (start[start.Length - 1] - '0');

                if (8 - l > 0)
                {
                    ans = 8 - l;
                    Console.WriteLine(ans);
                    return;
                }
                else
                {
                    var lt = int.Parse(start.Substring(start.Length - 2,2));
                    ans = Math.Min(80 - lt, 18 - l);
                    Console.WriteLine(ans == 80 - lt ? 80 - lt : 18 - l);
                    return;
                }
            }
            else
            {
                var l = (start[start.Length - 1] - '0');
                if (8 - l >= 0)
                {
                    var lt = int.Parse(start.Substring(start.Length - 2, 2));
                    ans = Math.Min(90 - lt, l + 8);
                    Console.WriteLine(ans == 90 - lt ? 90 - lt : l+8);
                    return;
                }
                else
                {
                    ans = l - 8;
                    Console.WriteLine(ans);
                    return;
                }
            }

        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Numerics;
namespace ConsoleApplication25
{
    class Solution
    {
        static void Main(string[] args)
        {
            var start = Console.ReadLine();

            var ans = 0;
            if (start.Contains('8') && start.IndexOf('8') <= start.Length - 2)
            {
                Console.WriteLine(1);
                return;
            }
            if (int.Parse(start) == 0)
            {
                Console.WriteLine(8);
                return;
            }
            if (int.Parse(start) == 8)
            {
                Console.WriteLine(10);
                return;
            }

            if (int.Parse(start) > 0)
            {
                var l = (start[start.Length - 1] - '0');

                if (8 - l > 0)
                {
                    ans = 8 - l;
                    Console.WriteLine(ans);
                    return;
                }
                else
                {
                    var lt = int.Parse(start.Substring(start.Length - 2,2));
                    ans = Math.Min(80 - lt, 18 - l);
                    Console.WriteLine(ans == 80 - lt ? 80 - lt : 18 - l);
                    return;
                }
            }
            else
            {
                var l = (start[start.Length - 1] - '0');
                if (8 - l >= 0)
                {
                    var lt = int.Parse(start.Substring(start.Length - 2, 2));
                    ans = Math.Min(90 - lt, l + 8);
                    Console.WriteLine(ans == 90 - lt ? 90 - lt : l+8);
                    return;
                }
                else
                {
                    ans = l - 8;
                    Console.WriteLine(ans);
                    return;
                }
            }

        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Numerics;
namespace ConsoleApplication25
{
    class Solution
    {
        static void Main(string[] args)
        {
            var start = Console.ReadLine();

            var ans = 0;

            if (int.Parse(start) > 0)
            {
                var l = (start[start.Length - 1] - '0');

                if (8 - l > 0)
                {
                    ans = 8 - l;
                    Console.WriteLine(ans);
                    return;
                }
                else
                {
                    var lt = int.Parse(start.Substring(start.Length - 2,2));
                    ans = Math.Min(80 - lt, 18 - l);
                    Console.WriteLine(ans == 80 - lt ? 80 - lt : 18 - l);
                    return;
                }
            }
            else
            {
                var l = (start[start.Length - 1] - '0');
                if (8 - l > 0)
                {
                    var lt = int.Parse(start.Substring(start.Length - 2, 2));
                    ans = Math.Min(90 - lt, l + 8);
                    Console.WriteLine(ans == 90 - lt ? 90 - lt : l+8);
                    return;
                }
                else
                {
                    ans = l - 8;
                    Console.WriteLine(ans);
                    return;
                }
            }

                Console.ReadLine();
        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Numerics;
namespace ConsoleApplication25
{
    class Solution
    {
        static void Main(string[] args)
        {
            var start = Console.ReadLine();

            var ans = 0;
            if (start.Contains('8') && start.IndexOf('8') <= start.Length - 2)
            {
                Console.WriteLine(1);
                return;
            }

            if (int.Parse(start) > 0)
            {
                var l = (start[start.Length - 1] - '0');

                if (8 - l > 0)
                {
                    ans = 8 - l;
                    Console.WriteLine(ans);
                    return;
                }
                else
                {
                    var lt = int.Parse(start.Substring(start.Length - 2,2));
                    ans = Math.Min(80 - lt, 18 - l);
                    Console.WriteLine(ans == 80 - lt ? 80 - lt : 18 - l);
                    return;
                }
            }
            else
            {
                var l = (start[start.Length - 1] - '0');
                if (8 - l > 0)
                {
                    var lt = int.Parse(start.Substring(start.Length - 2, 2));
                    ans = Math.Min(90 - lt, l + 8);
                    Console.WriteLine(ans == 90 - lt ? 90 - lt : l+8);
                    return;
                }
                else
                {
                    ans = l - 8;
                    Console.WriteLine(ans);
                    return;
                }
            }

                Console.ReadLine();
        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Numerics;
namespace ConsoleApplication25
{
    class Solution
    {
        static void Main(string[] args)
        {
            var start = Console.ReadLine();

            var ans = 0;
            if (start.Contains('8') && start.IndexOf('8') <= start.Length - 2)
            {
                Console.WriteLine(1);
                return;
            }
            if (int.Parse(start) == 0)
            {
                Console.WriteLine(8);
                return;
            }
            if (int.Parse(start) == 8)
            {
                Console.WriteLine(16);
                return;
            }

            if (int.Parse(start) > 0)
            {
                var l = (start[start.Length - 1] - '0');

                if (8 - l > 0)
                {
                    ans = 8 - l;
                    Console.WriteLine(ans);
                    return;
                }
                else
                {
                    var lt = int.Parse(start.Substring(start.Length - 2,2));
                    ans = Math.Min(80 - lt, 18 - l);
                    Console.WriteLine(ans == 80 - lt ? 80 - lt : 18 - l);
                    return;
                }
            }
            else
            {
                var l = (start[start.Length - 1] - '0');
                if (8 - l >= 0)
                {
                    var lt = int.Parse(start.Substring(start.Length - 2, 2));
                    ans = Math.Min(90 - lt, l + 8);
                    Console.WriteLine(ans == 90 - lt ? 90 - lt : l+8);
                    return;
                }
                else
                {
                    ans = l - 8;
                    Console.WriteLine(ans);
                    return;
                }
            }

        }
    }
}

using System;

public class Test
{
	public static int Main()
	{
	  long a=long.Parse(Console.ReadLine());
	  if(ce(a)){
	  	Console.WriteLine(0);
	  	  return 0;
	  }
	  int count=0;
	  while(true)
	  {
	  	a++;
	  	count++;
	  	if(ce(a))
	  	{
	  		Console.WriteLine(count);
	  		return 0;

	  	}

	  }

	  }

	public static bool ce(long a)
	{
		string s=a.ToString();
		int flag=0;
		for(int i=0;i<s.Length;i++)
		{
			if(s[i]=='8')
				flag=1;
		}
		if(flag==1)
		return true;
		else
		return false;
	}
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(File.OpenText("in.txt"));
            var n = long.Parse(Console.ReadLine());
            for (int i = 1; i < 20; i++)
            {
                var res = check(n + i);
                if (res)
                {
                    Console.WriteLine(i);
                    return;
                }
            }

        }

        static bool check(long n)
        {
            long temp = n;

            while (true)
            {
                var last = temp % 10;
                temp = temp / 10;
                if (last == 8)
                {
                    return true;
                }

                if (temp == 0)
                {
                    return false;
                }
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(File.OpenText("in.txt"));
            var n = long.Parse(Console.ReadLine());
            for (int i = 1; i < 20; i++)
            {
                var res = check(n + i);
                if (res)
                {
                    Console.WriteLine(i);
                    return;
                }
            }

        }

        static bool check(long n)
        {
            long temp = n;

            while (true)
            {
                var last = temp % 10;
                temp = Math.Abs(temp / 10);
                if (last == 8)
                {
                    return true;
                }

                if (temp == 0)
                {
                    return false;
                }
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HelloWorld
{
    class Test
    {
        static int n, c, l;

        public static void Main()
        {
          /*  MyStack stack = new MyStack(5);

            for (int j = 0; j < 5; j++)
            {
                stack.push(j);
            }

            Console.WriteLine(stack.isFull());
            Console.WriteLine(stack.getNumberOfElements());
            while (!stack.isEmpty())
            {
                Console.WriteLine(stack.pop());

            }

            Console.WriteLine(stack.isEmpty());
            Console.WriteLine(stack.getNumberOfElements());
            Console.WriteLine(stack.getSize());

            Program pr = new Program("Sanan", 19);
            Console.WriteLine("before change " + pr.getName());
            Program p = Program.change(pr);
            Console.WriteLine("after change " + pr.getName());
            Console.WriteLine(p);

            int a = 5;

            sqr(ref a);

           Console.WriteLine(a);

           int x  =9; int y =6;
           swap(ref x, ref y);

           Console.WriteLine("x = " + x + " y = " + y);

           double d = 10.1325;
           double ost;

           int  whole =  splitNumber(d, out ost);

           Console.WriteLine("Целая часть " + whole + "\n" + "Дробная часть " + ost);*/

            n = Convert.ToInt32(Console.ReadLine());
            l = n;

            while (true)
            {
                if (luckyNumber(n))
                {
                    c = n;
                    break;
                }
                else n++;
              }

            Console.WriteLine(Math.Abs(l - n));

         //  Console.ReadKey();
        }
        static bool luckyNumber(int n)
        {
            String S = n.ToString();
            return S.Contains("8");
        }

        static void sqr( ref int a)
        {
            a = a * a;
        }

        static void swap(ref int a, ref int b) {

            int temp = a;
            a = b;
            b = temp;

        }

        static int splitNumber(double d, out double ost)
        {
            int n = (int)d;
            ost = d - n;

            return n;
        }

    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace Task_TD
{

    class Program
    {

        public const int Diff = 20;

        static void Main(string[] args)
        {

            long a = Int64.Parse(Console.ReadLine());

            Console.WriteLine(GetResult(a));

            Console.ReadLine();
        }

        static long GetResult(long a)
        {
            long high = a + Diff;
            for (long i = a + 1; i < high; i++)
            {
                if (ContainsEight(i))
                    return i - a;
            }

            return -1;
        }

        static bool ContainsEight(long number)
        {
            while (number > 0)
            {
                if (number % 10 == 8)
                    return true;

                number = number / 10;
            }

            return false;
        }

    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
using System.Numerics;
using System.Threading;
using System.Diagnostics;

namespace StudyCSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            long stage, result = 0;
            byte[] Astage = {0};
            string buf;
            bool found = false;
            stage = Convert.ToInt32(Console.ReadLine());
            while (found == false && result <= 10)
            {
                stage++;
                result++;
                buf = stage.ToString();
                Astage = ArrCharToArrByte(buf, Astage);
                for (int i = 0; i < Astage.Length; i++)
                    if (Astage[i]==8)
                    {
                        found = true;
                        break;
                    }
            }
            Console.WriteLine(result);
        }

        static byte[] ArrCharToArrByte(string buf, byte[] stage)
        {
            stage = new byte[buf.Length];
            for (int i = 0; i < buf.Length; i++)
                Byte.TryParse(buf[i].ToString(), out stage[i]);
            return stage;
        }
    }
}

using System;
using System.Linq;

namespace tren
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            long[] mass = new long[16];
            for(int i = 0; i < 16; i++)
            {
                mass[i] = n + i;
            }
            for(int i = 1; i < mass.Count(); i++)
            {
                if (mass[i].ToString().Contains('8')) { Console.Write(i); return; }
            }
        }
    }
}

using System;
class Program
{
    static bool isLucky(long n)
    {
        while (n > 0)
        {
            if (n % 10 == 8)
            {
                return true;
            }
            n /= 10;
        }
        return false;
    }
    static void Main()
    {
        long b = 0;
        var a = long.Parse(Console.ReadLine());
        if (a < 0)
        {
            b = -a + 7;
            a = 7;
        }
        a++;
        b++;
        while (!isLucky(a))
        {
            a++;
            b++;
        }
        Console.WriteLine(b);
    }
}

using System;
namespace CodeForces
{
    public class A
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            long n = Convert.ToInt64(s);
            if (n >= 0)
            {
                if (s[s.Length - 1] < '8')
                    n += 8 - (s[s.Length - 1] - '0');
                else if (s.Length - 2 >= 0 && s[s.Length - 2] == '7')
                    n += 10 - (s[s.Length - 1] - '0');
                else if (s[s.Length - 1] == '8')
                    n += 10;
                else if (s[s.Length - 1] == '9')
                    n += 9;
            }
            else
                n = 8;
            Console.WriteLine(n);
            Environment.Exit(0);

        }
    }
}

    using System;
    namespace CodeForces
    {
        public class A
        {
            public static void Main(string[] args)
            {
                string s = Console.ReadLine();
                long n = Convert.ToInt64(s);
                long ans = n;
                if (n >= 0)
                {
                    if (s[s.Length - 1] < '8')
                        n += 8 - (s[s.Length - 1] - '0');
                    else if (s.Length - 2 >= 0 && s[s.Length - 2] == '7')
                        n += 10 - (s[s.Length - 1] - '0');
                    else if (s[s.Length - 1] == '8')
                        n += 10;
                    else if (s[s.Length - 1] == '9')
                        n += 9;
                }
                else
                    n = 8;

                ans = Math.Abs(ans - n);
                Console.WriteLine(ans);
                Environment.Exit(0);

            }
        }
    }

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces284
{
    class Program
    {
        static void Main(string[] args)
        {
            /*ulong n;
            ulong m;
            ulong b;
            string s = Console.ReadLine();
            char[] ch = s.ToCharArray();
            if (ch[0] == '-')
            {
                n = ulong.Parse(s);
                b = n;
                char[] bc = b.ToString().ToCharArray();
                while (bc[bc.Length - 1] != 8)
                {
                    b++;
                    bc = b.ToString().ToCharArray();
                }
            }
            else
            {
                m = ulong.Parse(s);
                b = m;
                char[] bc = b.ToString().ToCharArray();
                while ((bc[bc.Length - 1] != 8)||(bc[0]=='-'))
                {
                    b++;
                    bc = b.ToString().ToCharArray();
                }
            }
            Console.WriteLine(b);*/
            long n = long.Parse(Console.ReadLine());
            int k = 0;
            bool flag = true;
            if (n > 0)
            {
                while (flag)
                {
                    n++;
                    k++;
                    char[] ch = n.ToString().ToCharArray();
                    for (int i = 0; i < ch.Length; i++)
                    {
                        if (ch[i] == '8')
                            flag = false;
                    }

                }
            }
            else k = (int)Math.Abs(n) + 8;
            Console.WriteLine(k);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces284
{
    class Program
    {
        static void Main(string[] args)
        {
            /*ulong n;
            ulong m;
            ulong b;
            string s = Console.ReadLine();
            char[] ch = s.ToCharArray();
            if (ch[0] == '-')
            {
                n = ulong.Parse(s);
                b = n;
                char[] bc = b.ToString().ToCharArray();
                while (bc[bc.Length - 1] != 8)
                {
                    b++;
                    bc = b.ToString().ToCharArray();
                }
            }
            else
            {
                m = ulong.Parse(s);
                b = m;
                char[] bc = b.ToString().ToCharArray();
                while ((bc[bc.Length - 1] != 8)||(bc[0]=='-'))
                {
                    b++;
                    bc = b.ToString().ToCharArray();
                }
            }
            Console.WriteLine(b);*/
            long n = long.Parse(Console.ReadLine());
            int k = 0;
            bool flag = true;
            if (n > 0)
            {
                char[] ch = n.ToString().ToCharArray();
                for (int i = 0; i < ch.Length; i++)
                {
                    if (ch[i] == '8')
                        flag = false;
                }
                while (flag)
                {
                    n++;
                    k++;
                    ch = n.ToString().ToCharArray();
                    for (int i = 0; i < ch.Length; i++)
                    {
                        if (ch[i] == '8')
                            flag = false;
                    }

                }
            }
            else k = (int)Math.Abs(n) + 8;
            Console.WriteLine(k);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces284
{
    class Program
    {
        static void Main(string[] args)
        {
            /*ulong n;
            ulong m;
            ulong b;
            string s = Console.ReadLine();
            char[] ch = s.ToCharArray();
            if (ch[0] == '-')
            {
                n = ulong.Parse(s);
                b = n;
                char[] bc = b.ToString().ToCharArray();
                while (bc[bc.Length - 1] != 8)
                {
                    b++;
                    bc = b.ToString().ToCharArray();
                }
            }
            else
            {
                m = ulong.Parse(s);
                b = m;
                char[] bc = b.ToString().ToCharArray();
                while ((bc[bc.Length - 1] != 8)||(bc[0]=='-'))
                {
                    b++;
                    bc = b.ToString().ToCharArray();
                }
            }
            Console.WriteLine(b);*/
            long n = long.Parse(Console.ReadLine());
            int k = 0;
            bool flag = true;
            if (n > 0)
            {
                char[] ch = n.ToString().ToCharArray();
                while (flag)
                {
                    n++;
                    k++;
                    ch = n.ToString().ToCharArray();
                    for (int i = 0; i < ch.Length; i++)
                    {
                        if (ch[i] == '8')
                            flag = false;
                    }

                }
            }
            else k = (int)Math.Abs(n) + 8;
            Console.WriteLine(k);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace a2oj
{
    class Program
    {
        static bool cheight(int num)
        {
            while(num>0)
            {
                if (num % 10 != 8)
                    num /= 10;
                else
                    return true;
            }
            return false;
        }

        static void Main(string[] args)
        {
            int n;
            int t;
            n = int.Parse(Console.ReadLine());
            t=n;
            //List<int> val = new List<int>();
            //string s= Console.ReadLine();
            //string []all=s.Split(' ');
            //foreach(string st in all)
            //{
            //    val.Add(int.Parse(st));
            //}
            n++;
            while (!cheight(n))
                n++;
            Console.WriteLine(n - t);

            //Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace a2oj
{
    class Program
    {

        static void Main(string[] args)
        {
            int n;
            n = int.Parse(Console.ReadLine());
            //List<int> val = new List<int>();
            //string s= Console.ReadLine();
            //string []all=s.Split(' ');
            //foreach(string st in all)
            //{
            //    val.Add(int.Parse(st));
            //}
            if(n>=0)
            {
                int unit = n % 10;
                n /= 10;
                int tens = n % 10;
                if(tens!=7)
                {
                    if (unit < 8)
                        Console.WriteLine(8 - unit);
                    else if (unit == 8)
                        Console.WriteLine(10);
                    else
                        Console.WriteLine(9);
                }
                else
                {
                    if (unit < 8)
                        Console.WriteLine(8 - unit);
                    else if (unit == 8)
                        Console.WriteLine(2);
                    else
                        Console.WriteLine(1);
                }

            }
            else if(n<0&&n>-9)
            {
                if (n == -8)
                    Console.WriteLine(10);
                else
                    Console.WriteLine(8 - n);
            }
            else
            {
                int unit =n % 10;
                n /= 10;
                int tens =n % 10;
                if(tens!= -9)
                {
                    if (unit == -9)
                        Console.WriteLine(1);
                    else if (unit == -8)
                        Console.WriteLine(10);
                    else
                    {
                        Console.WriteLine(10 - 8 +Math.Abs( unit));
                    }
                }
                else
                {
                    if (unit == -9)
                        Console.WriteLine(1);
                    else if (unit == -8)
                        Console.WriteLine(8);
                    else
                        Console.WriteLine(unit);
                }

            }

            //Console.ReadKey();
        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace Giga_tower
{
    class Program
    {
        static void Main(string[] args)
        {
            var inicio = int.Parse(Console.ReadLine());

            for (int i = 0; i <=16 ; i++)
            {
                if ((inicio + i).ToString().Contains('8'))
                {
                    Console.WriteLine(i);
                    return;
                }
            }
            Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            int n,i = 0;
            s = Console.ReadLine();
            n = Convert.ToInt32(s);
            bool x = true;
            while (x)
            {
                i++;
                n++;
                int j,temp = n;
                while (temp>0)
                {
                    j = temp % 10;
                    if (j == 8)
                    {
                        x = false;
                        break;
                    }
                    temp /= 10;
                }
            }
            Console.Write(i);
            Console.WriteLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            int n,i = 0;
            s = Console.ReadLine();
            n = Convert.ToInt32(s);
            bool x = true;
            while (x)
            {
                i++;
                n++;
                int j,temp = n;
                while (temp>0)
                {
                    j = temp % 10;
                    if (j == 8 || j == -8)
                    {
                        x = false;
                        break;
                    }
                    temp /= 10;
                }
            }
            Console.Write(i);
            Console.WriteLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            int n,i = 0;
            s = Console.ReadLine();
            n = Convert.ToInt32(s);
            bool x = true;
            while (x)
            {
                i++;
                n++;
                int j,temp = n;
                while (temp>0)
                {
                    j = temp % 10;
                    if (j == 8)
                    {
                        x = false;
                        break;
                    }
                    temp /= 10;
                }
            }
            Console.Write(i-1);
            Console.WriteLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            int n,i = 0;
            s = Console.ReadLine();
            n = Convert.ToInt32(s);
            bool x = true;
            while (x)
            {
                int j,temp = n;
                while (temp>0)
                {
                    j = temp % 10;
                    if (j == 8)
                    {
                        x = false;
                        break;
                    }
                    temp /= 10;
                }
                n++;
                i++;
            }
            Console.Write(i-1);
            Console.WriteLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            int n,i = 0;
            s = Console.ReadLine();
            n = Convert.ToInt32(s);
            bool x = true;
            while (x)
            {
                i++;
                int j,temp = n;
                while (temp>0)
                {
                    j = temp % 10;
                    if (j == 8)
                    {
                        x = false;
                        break;
                    }
                    temp /= 10;
                }
                n++;
            }
            Console.Write(i-1);
            Console.WriteLine();
        }
    }
}