Polycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is sold for k burles. Assume that there is an unlimited number of such shovels in the shop.In his pocket Polycarp has an unlimited number of "10-burle coins" and exactly one coin of r burles (1 ≤ r ≤ 9).What is the minimum number of shovels Polycarp has to buy so that he can pay for the purchase without any change? It is obvious that he can pay for 10 shovels without any change (by paying the requied amount of 10-burle coins and not using the coin of r burles). But perhaps he can buy fewer shovels and pay without any change. Note that Polycarp should buy at least one shovel.

The single line of input contains two integers k and r (1 ≤ k ≤ 1000, 1 ≤ r ≤ 9) — the price of one shovel and the denomination of the coin in Polycarp's pocket that is different from "10-burle coins".  Remember that he has an unlimited number of coins in the denomination of 10, that is, Polycarp has enough money to buy any number of shovels.

Print the required minimum number of shovels Polycarp has to buy so that he can pay for them without any change.

NoteIn the first example Polycarp can buy 9 shovels and pay 9·117 = 1053 burles. Indeed, he can pay this sum by using 10-burle coins and one 3-burle coin. He can't buy fewer shovels without any change.In the second example it is enough for Polycarp to buy one shovel.In the third example Polycarp should buy two shovels and pay 2·15 = 30 burles. It is obvious that he can pay this sum without any change.

import java.util.Random;
import java.util.ArrayList;
import java.util.Scanner;
import java.lang.Math;
import static java.lang.Math.abs;
/**
 *
 * @author LOL
 */
public class JavaApplication8 {

 public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int K = input.nextInt();
int R = input.nextInt();
int sum=1;
    while(true)
    {
        if((K*sum)%10==R||(K*sum)%10==0)
        {
            System.out.println(sum);
            break;

        }
        ++sum;
        }

    }

    }

import java.util.*;
import java.io.*;
public class Main {
	public static void main(String ahh[]) {
		Cin in = new Cin();
		int k = in.nextInt(),r= in.nextInt();
		for(int i = 1; i <= 9; i++) {
			if((k*i % 10) - r == 0 || k*i % 10 == 0) {
				wr.print(i);
				break;
			}
		}
		wr.close();
	}

// IO -> :
	static PrintWriter wr = new PrintWriter(System.out);
	static class Cin {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = null;
		String next() {
			while(st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(reader.readLine());
				} catch(Exception e) {
					e.printStackTrace();
					System.exit(1);
				}
			}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());}
	}
}

import java.util.*;
public class Main{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int c=0;
        for(int i=1;i<=100;i++)
        {
            if(((n*i)%10)==k||(n*i)%10==0)
            {
            c=i;
            break;
            }
        }
        System.out.println(c);
    }
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package codeforces.submissions;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 *
 * @author Joe
 */
public class CodeforcesSubmissions {

    /**
     * @param args the command line arguments
     */
    public static int getMinAmountOfShovals(int s, int n) {
        int ans = 1;
        while(true){
            if((ans * s) % 10 == n || (ans * s) % 10 == 0) break;
            ans++;
        }
        return ans;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int n = sc.nextInt();

        System.out.println(getMinAmountOfShovals(s, n));
    }

}

import java.util.Scanner;

/**
 * https://codeforces.com/problemset/problem/732/A
 */
public class Problem732A {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        scanner.useDelimiter(System.lineSeparator());
        String[] input = scanner.next().split(" ");
        scanner.close();

        int shovelCost = Integer.parseInt(input[0]);
        int coinValue = Integer.parseInt(input[1]);
        int result = 0;

        if (shovelCost == coinValue) {
            result++;
        } else if (shovelCost <= 9 && coinValue % shovelCost == 0) {
            result = coinValue / shovelCost;
        } else if (shovelCost % 10 == 0) {
            result++;
        } else {
            int wasted = 0;
            if (shovelCost < 10) {
                while (wasted < 10) {
                    wasted += shovelCost;
                    result++;
                }
            }
            if (wasted != 10) {
                if (shovelCost > 10) {
                    wasted += shovelCost;
                    result++;
                }
                if ((wasted - (wasted / 10) * 10) == coinValue || wasted % 10 == 0) {
                } else {
                    do {
                        wasted += shovelCost;
                        if ((wasted - (wasted / 10) * 10) == coinValue || wasted % 10 == 0) {
                            result++;
                            break;
                        }
                        result++;
                    } while (true);
                }
            }
        }

        System.out.println(result);
    }
}

import java.util.*;

public class Cont {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System. in);
		int k = sc.nextInt();
		int r = sc.nextInt();
		int s = 1;
		while(((k*s)-r)%10!=0 && (k*s)%10!=0) {
			s++;
		}
		System.out.print(s);
	}
}

import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

public class Solution {
    public static void main(String[] args){
        Scanner sn = new Scanner (System.in);
        int price = sn.nextInt();
        int sum=price;
        int cha = sn.nextInt();
        int x=1;
        while(true){

            if(sum%10==0 || sum % 10 == cha){
                break;
            }
            x++;
            sum = sum+price;

        }
        System.out.print(x);

    }
}

import java.util.*;
import java.io.*;

public class CF732 {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int k = in.nextInt(), r = in.nextInt(), count = 1, rem = k%10;

        while(rem!=0 && rem!=r){
            rem = (rem + k%10) %10;
            count++;
        }

        out.println(count);

        out.flush();
        out.close();
        in.close();
    }
}

import java.util.*;
import java.lang.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int r = scan.nextInt();
        int count = 0;
        int i =1;
        while (true){
            if(((k*i)-r)%10==0 || (k*i)%10 == 0){
                count = i;
                break;
            }
            i++;
        }
        System.out.println(count);
    }
}

import java.util.Scanner;
//import java.lang.Math;

public class buy_a_shovel {
    public static void main(String[] args) {
        solve();
    }

    static void solve() {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int r = sc.nextInt();
        int shovels = 1;
        while (true) {
            if ((shovels*k % 10 == r) || (shovels*k % 10 == 0)) {
                break;
            }
            shovels++;
        }
        System.out.println(shovels);
        sc.close();
    }
}

import java.util.Scanner;
public class ProblemSolving {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int price = sc.nextInt();
        int change = sc.nextInt();
        int count=1;
        int p= price;
        //int total = price + change;
        int n =1;
        while(true)
        {
        if( price * n % 10 ==0 || (price * n )%10==change )
            break;

        else
        {
        count++;
        n+=1;
        }
        }
         System.out.println(count);
        }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;

public class Hello {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        long nextLong() {

            return Long.parseLong(next());
        }

        BigInteger nextBigIntger() {
            BigInteger bb = new BigInteger(next());
            return bb;
        }
    }

    public static void main(String args[]) {
        FastReader sc = new FastReader();
        int k = sc.nextInt();
        int r= sc.nextInt();
        for(int i=1;;i++){
            int cost=i*k;
            if(cost%10==r || cost%10==0){
                System.out.println(i);return;}
        }
    }

}

import java.util.*;
public class Pb34 {
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int k = in.nextInt();
int r= in.nextInt();
int c;int count=1;int price=k;
    while(k<=1000)
    {
	c=((price/10)*10);
	if(c==price||c+r==price)
	{
		System.out.println(count);
		break;
	}
	else
		{
			count++;
			price=k*count;
		}
}
}
}

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{

		Scanner in = new Scanner(System.in);

		int k = in.nextInt() ;
		int r = in.nextInt() ;
	//	int n = in.nextInt() ;

		for (int i = 1; i<10; i++ )
		{
			if (((k*i)%10==r)||(k*i%10==0))
			{
				{
					System.out.println(i) ;
					System.exit(0) ;
				}
			}

		}

		System.out.println(10) ;

	}

/*	public static int gcd(int a, int b)
	{

		if (b==0)
			return a ;

		else
			return gcd(b,a%b) ;

	}	*/

}

import java.util.Scanner;

/**
 * Created by akshaysharma on 13/01/17.
 */
public class Problem732A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int r = sc.nextInt();
        int count = 0, result = Integer.MAX_VALUE;
        while ((k * count - r) % 10 != 0 && count < 10) {
            count++;
        }
        if (k % 10 == 0) {
            result = 1;
        } else if (k % 5 == 0) {
            result = 2;
        } else if (k % 2 == 0)
            result = 5;
        System.out.print(Math.min(count, result));
    }
}

import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int s=1,j=0;
		int a=sc.nextInt();
		int b=sc.nextInt();
		for(j=1;j<11;j++){
		    if((a*j)%10==b || ((a*j)%10==0)){
		        System.out.print(j);
		        break;
		    }
		}
	}
}

//Written by Shagoto
import java.util.*;
public class Main
{
  public static void main(String[]args)
  {
    Scanner read = new Scanner(System.in);

    int k = read.nextInt();
    int r = read.nextInt();

    if(k < 10)
    {
      if(r == k)
      {
        System.out.println(1);
      }
      else if(r > k)
      {
        if(r % k == 0)
        {
          System.out.println(r / k);
        }
        else
        {
          int t = 1;
          while(true)
          {
            if((10*t) % k == 0)
            {
              System.out.println((10*t) / k);
              break;
            }
            else if((10*t + r) % k == 0)
            {
              System.out.println((10*t + r) / k);
              break;
            }
            else
            {
              t++;
            }
          }
        }
      }
      else
      {
        int t = 1;
        while(true)
        {
          if((10*t) % k == 0)
          {
            System.out.println((10*t) / k);
            break;
          }
          else if((10*t + r) % k == 0)
          {
            System.out.println((10*t + r) / k);
            break;
          }
          else
          {
            t++;
          }
        }
      }
    }

    else
    {
      int t = 1;
      while(true)
      {
        if((10*t) % k == 0)
        {
          System.out.println((10*t) / k);
          break;
        }
        else if((10*t + r) % k == 0)
        {
          System.out.println((10*t + r) / k);
          break;
        }
        else
        {
          t++;
        }
      }
    }
  }
}

import java.util.*;
public class Main {

    public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	int k=sc.nextInt();
	int r=sc.nextInt();
	int q=0;
	int z=0;

            for (int i = 1; i <= 9; i++)
            {
                        q = k * i;
                        z = q % 10;
                        if(z==0) {
                            System.out.println(i);
                            break;
                        }
                        else if (z == r) {
                            System.out.println(i);
                            break;
                        }
                        else {
                            continue;
                        }
                    }
                }
        }

import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main{
    public static void main(String[] args) throws IOException {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        int k = sc.nextInt();
        int r = sc.nextInt();
        int i = 1;
        int count = 0;
        while (true) {
            int a = k * i;
            if ((a % 10 == r) || (a % 10 == 0)) {
                count++;
                break;
            }
            else {
                i++;
                count++;
            }
        }
        out.println(count);

        out.close();
    }

    public static PrintWriter out;

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public MyScanner(String file) throws IOException {
            br = new BufferedReader(new FileReader(file));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.util.Scanner;

public class Buy_a_Shovel {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int k = sc.nextInt(), r = sc.nextInt();
		int i=1;
		while((i*k)%10!=r && (i*k)%10!=0) {
			i++;
		}
		System.out.println(i);
	}
}

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		int k = in.nextInt();
		int r = in.nextInt();

		int counter = 0;
		int lastDigit = k % 10;

		if(k == r) {
			System.out.println(1);
			System.exit(0);

		}
		for(int i = 1;  lastDigit != r && lastDigit != 0 ; i++) {

			 lastDigit = (k * i) % 10;

			counter++;

		}
		if(counter == 0) {
			System.out.println(1);
		}else {
		System.out.println(counter);
		}

	}
}

import java.io.*;
import java.util.*;

public class Main {

    public static void main(String [] args){
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Integer readFromFile=new Integer(1);
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskD {

        class Pair{
            int first;
            int second;
            Pair(int first, int second){
                this.first = first;
                this.second = second;
            }
            Pair(){}
        }
        class Comp implements Comparator<Integer>{
            @Override
            public int compare(Integer o1, Integer o2) {
                return (o1-o2)*-1;
            }
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int one = in.nextInt();
            int oct = n%10;
            if(oct==0 || oct-one==0){
                out.println("1");
                return;
            }
            int sum = 0;
            for(int i=1; i<=10; i++){
                if((((oct*i)%10)-one==0) || (oct*i)%10==0){
                    out.println(i);
                    break;
                }
            }
        }
    }
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;
        String st1;
        File file = new File("text.txt");
        public InputReader(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
            st = null;
        }
        public InputReader(int i) {
            try {
                br  = new BufferedReader(
                        new InputStreamReader(new FileInputStream(file)));
            } catch (FileNotFoundException e1) {
                System.out.println("File is not find");
            }
            st = null;
        }
        public String next(){
            while (st==null || !st.hasMoreTokens()){
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public String nextLine(){
            try {
                st1 = new String(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return st1;
        }
        public int nextInt()  {return Integer.parseInt(next());}
        public long nextLong(){
            return Long.parseLong(next());
        }
        public Double nextDouble(){
            return Double.parseDouble(next());
        }
        public Byte nextByte() {
            return Byte.parseByte(next());
        }
        private int idx;
        public Character nextChar() {
            if(st1==null) {
                st1 = next();
                idx = 0;
            }
            if(idx!=(st1.length())-1){
                return st1.charAt(idx++);
            }else{
                char  c= st1.charAt(idx);
                st1 = null;
                return c;
            }
        }
        public void newFile() {
            try {
                FileWriter write = new FileWriter(file);
                write.write("something for cheaking");
                write.close();

            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class BuyaShovel {
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String [] data = reader.readLine().split(" ");
		int price = Integer.parseInt(data[0]);
		int burle = Integer.parseInt(data[1]);
		int total =price;
		int c =1;
		while(total % 10 != burle && total %10 !=0) {
			total+=price;
			c++;
		}
		System.out.println(c);
	}
}

import java.util.Scanner;

public class Main {
	static int n;
	static int m;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m =sc.nextInt();
		dfs(1);
	}

	private static void dfs(int i) {
		// TODO Auto-generated method stub
		int sum=n*i;
		if(sum%10==m||sum%10==0) {
			System.out.println(i);
			return;
		}else {
			dfs(i+1);
		}
	}

}

import java.util.Scanner;

public class A732 {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int r = sc.nextInt();
        int n = 10;
        if(k%10 == 0){
            System.out.println(1);
        }else if(r%k == 0){System.out.println(r/k);}
        else if(k == r){System.out.println(1);}
        else if(k == 1){System.out.println(r);}
        else if((10+r)% k == 0){System.out.println((10+r)/k);}
        else if((20+r)% k == 0){System.out.println((20+r)/k);}
        else if((30+r)% k == 0){System.out.println((30+r)/k);}
        else if(k%5 == 0 && r == 5){System.out.println(k/10);}
        else if(k%5 == 0){
            System.out.println(2);
        }else if((k*r)%10 == r){System.out.println(r);}
        else if((k*5)%10 == 0){System.out.println(5);}
        else{
        while((n+r)%k != 0){
            n+= 10;
        }
        System.out.println((n + r)/k);}
    }
}

public class Shovel
{
  //Ricardo Guevara _ BUY A SHOVEL PROBLEM
  public static void main(String [] args)
  {
    final int coin_val = 10;
    int k,
        c,
        n = 1;
    String input;

    java.io.BufferedReader reader =
    new java.io.BufferedReader(new java.io.InputStreamReader(System.in));

    while(true)
    {
      try
      {
        input = reader.readLine();
        k = Integer.parseInt(input.substring(0,input.indexOf(" ")));
        c = Integer.parseInt(input.substring(input.indexOf(" ")+1,input.length()));
        break;
      }
      catch(NumberFormatException nfe)
      {
        System.out.println("_______________\ninvalid input, please start again");
      }
      catch(java.io.IOException ioe)
      {
         ioe.printStackTrace();
      }
    }

    while(((n*k)%10) != c && ((n*k)%10) != 0)
    {
      n++;
    }
    System.out.println(n);

  }
}

import java.util.*;

public class Solving {

private static Scanner in =new Scanner(System.in);
 public static int lower(int arr[], int n, int X) {
     if (X < arr[0])
         return 0;
     else if (X > arr[n - 1])
         return n;
     int lowerPnt = 0;
     int i = 1;
     while (i < n && arr[i] < X) {
         lowerPnt = i;
         i = i * 2;
     }
     while (lowerPnt < n && arr[lowerPnt] < X)
         lowerPnt++;

     return lowerPnt;
    }
 public static void main(String[] args){
   int n=in.nextInt();
   int tmp=n;
   int k=in.nextInt();
   int count=0;
   if(n==1)
         System.out.println(k);
   else{
       if(n%10==0||n%10==k)
       count=0;
   else{
        while(n%10!=k){
            if(n%10==0)
                break;
            else{
            count++;
            n+=tmp;
            }
        }
   }
     System.out.println(count+1);
   }
 }
}

import java.util.*;

public class ProblemSolving {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int shovelPrice = scan.nextInt();
        int otherCoin = scan.nextInt();
        int fixedCoin = 10;
        int counter = 1;
        while(true){
            if((shovelPrice*counter)%10==otherCoin||(shovelPrice*counter)%10==0){
                System.out.println(counter);
                break;
            }
            counter++;
        }

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out=new PrintWriter(System.out);

        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int k=Integer.parseInt(st.nextToken());

        int r=Integer.parseInt(st.nextToken());
        int max1=0;
        int max=11;
        int u=k%10;
        for(int i=1;i<11;i++){
            if((i*u)%10==0){
                max1=i;
                break;

            }
        }
        for (int i = 1; i <11 ; i++) {
            if((i*u)%10==r){
                max=i;
                break;
            }

        }
        if(max1<max)
            out.println(max1);
        else
            out.println(max);

        out.flush();

    }
}

import java.util.*;
import java.io.*;
public class Main {
	 public static void main (String args[]){
	        Scanner sc=new Scanner(System.in);

	        int k=sc.nextInt();
	        int r=sc.nextInt();
	       boolean n=true;
	       int i=0,p=k;

	       while(n) {
	    	   if(k%10==r || k%10==0) {
	    		   System.out.println(i+1);
	    		   n=false;
	    	   }else {
	    		   k+=p;
	    		   i++;
	    	   }
	       }
}}

import java.io.*;

import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class apples{

    public static void main(String[] args) {

    	Scanner zizo=new Scanner(System.in);
    	int k=zizo.nextInt();
    	int r=zizo.nextInt();
    	int c=1;
    	int sum=k;
    	while(1==1) {
    		if(sum%10==0) break;
    		if((sum-r)%10==0) break;
    		c+=1;
    		sum+=k;
    	}

    	System.out.println(c);
    	}

		 }

import java.util.Scanner;

public class JavaApplication94 {

    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        int k=input.nextInt();
        int r=input.nextInt();
        int sum=1;
        for(int i=0;i<9;i++){
            if((k*sum)%10==r ||(k*sum)%10==0){
                System.out.println(sum);
                break;
        } sum++;
    }

}}

import java.util.*;
import java.lang.*;
import java.io.*;

public class Codechef
{
	static final long mod = (int)1e9+7;

	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int r = sc.nextInt();

		for(int i = 1;;i++) {
			if(((k*i)-r)%10 == 0 || (k*i)%10 == 0)
			{
				System.out.println(i);
				break;
			}
		}
		return;
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Buy_a_Shovel {

public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String h[] = br.readLine().split(" ");
		int k = Integer.parseInt(h[0]);
		int r = Integer.parseInt(h[1]);

		int ans=1;
		boolean f=false;
		if(k%10 == 0)
		{
			ans=1;
			f = true;
		}
		else if(k % 5 == 0)
		{
			ans=2;
			f = true;
		}
		else if(k % 2 == 0)
		{
			ans=5;
			f = true;
		}

		int temp=1;boolean flag=true;
		while((k*temp-r)%10 != 0)
		{
			temp++;

			if(temp > ans && f)
			{
				flag = false;
				break;
			}
		}
		if(flag)
			System.out.println(temp);
		else
			System.out.println(ans);

	}

}

//Either the number should be divisible by 10 or it should leave a remainder of (change specified to us)

import java.util.Scanner;
public class Solution
{
	public static void main(String[] args)
	{
		Scanner reader = new Scanner (System.in);
		int a = reader.nextInt();
		int b = reader.nextInt();
		int i=1;
		for(;i<10;i++)
			if(a*i%10==0 || (a*i-b)%10==0)
				break;
		System.out.println(i);
	}
}

import java.util.Scanner;
import java.util.*;

public class LearningJava {

	 public static void main(String[] args) {
		 int n,r,i,c=1;
		 Scanner sc =new Scanner(System.in);
		 n=sc.nextInt();
		 r=sc.nextInt();
		 i =n;
		 while((n-r) %10!=0 && n%10!=0)
		 {
		 n=n+i;
		 c++;
		 }
		 System.out.print(c);
		 }
		 }

import java.util.Scanner;
public class NewMain {
    public static void main(String[] args){
Scanner f=new Scanner(System.in);
String s=f.nextLine();
  int k=Integer.parseInt(s.substring(0, s.indexOf(" "))),r=Integer.parseInt(s.substring(s.indexOf(" ")+1));
    for(int x=1;x>0;x++)
   if((k*x)%10==0||(k*x)%10==r){
System.out.print(x);
   break;
   }
   }
       }

import java.io.*;
import java.util.*;
public  class cf
{
    public static void main(String[] args)
    {
        Scanner in=new Scanner(System.in);
        int a=in.nextInt();
        a=a%10;
        int b=in.nextInt();
        int x=0;
        while((a*++x)%10!=b&&(a*x)%10!=0);
        System.out.println(x);
    }
}

import java.util.Scanner;

public class _732A_BuyAShovel {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int k = input.nextInt();
        int r = input.nextInt();
        int k2 = k % 10;
        int x = 1;
        while (k2 % 10 != r && k2 % 10 !=0) {
            x++;
            k2 += k % 10;
        }
        System.out.println(x);
    }
}

import java.util.Scanner;
public class BuyAShovel {

	public static void main(String[] args) {
		Scanner in = new Scanner (System.in);
		short k = in.nextShort();
		byte r = in.nextByte();
		if (r % k == 0)
		{
			System.out.println(r / k);
			in.close();
			return;
		}

		int sum = 0;
		for (;;)
		{
			sum += 10;

			if (sum % k == 0 || (sum + r) % k == 0)
			{
				System.out.println((sum % k == 0)? sum / k: (sum + r) / k);
				break;
			}
		}
		in.close();

	}

}

import java.util.Scanner;
public class lol{
   public static void main(String[] args) {
      Scanner in = new Scanner(System.in);
      int price=in.nextInt();
      int coin=in.nextInt();
      int r=0,count=0,p=0,l=0;
      while(p>=0){
          if(price<=9 & price<coin){
          count++;
          l+=price;
          if(l/10==coin || l%10==0 || l==coin)
          p=-1;
          }
          else{
           if(price%10==0){
        count++;
      p=-1;
      }
           else{
      if(price%10==0 || r%10==0 & r!=0){
        count=r/price;
      p=-1;
      }
      else{
   r+=price;
      count++;
      p=r-coin;
      if(p%10==0)
      p=-1;
      }
          }
          }
      }

              System.out.println(count);

     }

}

import java.util.*;
public class CodeForces{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int price = sc.nextInt();
		int r = sc.nextInt();
		for(int i=1;i<100;i++){
			// sum = price *i - r;
			if(((price*i) %10 == r)|| ((price*i)%10 == 0)){
				System.out.println(i);
				break;
			}
		}

	}
}

import java.io.*;
import java.util.*;
public class forces
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int k=sc.nextInt();
        int r=sc.nextInt();
        int i=0,h=1;
        while(true)
        {
            i++;
            h=k*i;
            if(h%10==0||h%10==r)
            {
                break;
            }
        }
        System.out.println(i);
    }
}

// luogu-judger-enable-o2
import java.util.Scanner;

public class Main {
	static int n;
	static int m;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m =sc.nextInt();
		dfs(1);
	}

	private static void dfs(int i) {
		// TODO Auto-generated method stub
		int sum=n*i;
		if(sum%10==m||sum%10==0) {
			System.out.println(i);
			return;
		}else {
			dfs(i+1);
		}
	}

}

import java.util.*;

public class Solution {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int k = in.nextInt();
        int r = in.nextInt();

        int result = 10;

        for (int q = 1; q < 10; q += 1) {
            int p = (q * k) % 10;
            if (p == r || p == 0) {
                result = q;
                break;
            }
        }

        System.out.println(result);
    }
}

import java.util.Scanner;

public class BuyaShovel {

    public static void main(String[] args) {
        Scanner in =new Scanner(System.in);
        int cost=in.nextInt();
        int charge=in.nextInt();
        int result=cost;
        int count=1;
        while(result%10!=0&&result%10!=charge){
            result+=cost;
            count++;
        }
        System.out.println(count);

    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Shovels {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		StringTokenizer st=new StringTokenizer(s);
		int price=Integer.parseInt(st.nextToken());
		int coin=Integer.parseInt(st.nextToken());
		int total=0;
		int mini=0;
		int coinizer=0;
			coinizer=coinizer+coin;
			if(coinizer%price==0) {
				mini=coin/price;
			}

		int mini1=0;
		for(int i=0;i<price;i++) {
			total=total+10;
			if((total%price)==0 ) {
				mini1=total/price;
				break;
			}

				if((total+coin)%price==0) {
					mini1=(total+coin)/price;
					break;
				}

		}
		if(mini<=mini1 && mini!=0) {
			System.out.print(mini);
		}
		else {
			System.out.print(mini1);
		}
	}

}

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner scan =new Scanner(System.in);
		int k = scan.nextInt();
		k = k % 10;

		int r = scan.nextInt();
		int returnValue=0;
		int count=1;

		if(k%10 == 0 || k==r)
			returnValue=1;
		else if(k==5)
			returnValue=2;
		else if(r>k && r%k ==0)
		{
			returnValue=r/k;
			if(k%2==0 && returnValue > 5)
				returnValue=5;
		}

		else
		{
			int addend = k;
			int m=5;
			if(k%2!=0)
				m=10;
			while(k!=r && count < m)
			{
				k= k +addend;
				count++;
				if(k > 10)
					k = k - 10;
			}

		returnValue=count;
		}

		System.out.println(returnValue);
	}
}

import java.util.Scanner;

/**
 *
 * @author Akatsuki
 */
public class BuyAShovel {

    public static void main(String ar[]){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int K=sc.nextInt();
        if(N==K || N%10==0){
            System.out.println("1");
       return;
        }
        else
            for(int i=1;i<=9;i++){
                if(((N*i)-K)%10==0 || (N*i)%10==0){
                    System.out.println(i);
                  return;
                }
            }

        }

    }

import java.util.Scanner;
public class TaskSh {

        public static void main(String[] args) {
            Scanner sc=new Scanner(System.in);
            int k=sc.nextInt();
            int r=sc.nextInt();
            int x=k;
            int count=1;
            while(true){
                if(x%10==r||x%10==0){
                break;
                }else{
                       count++;
                       x=x+k;
                        }
    }
            System.out.println(count);

        }
}

import javax.swing.plaf.synth.SynthLookAndFeel;
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
public class CP {
    static Scanner sc = new Scanner(System.in);
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()

        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static int lowerBound
    (Integer[] array, int length, int value) {
        int l = 0;
        int r = length;
        while (l < r) {
            int mid = (l + r) / 2;
            if (value < array[mid]) {
                r = mid;
            } else {
                l = mid + 1;
            }
        }
        return l;
    }
    public static long gcd(long a, long b){
        if (b == 0)
            return a;
        else return gcd(b, a % b);
    }
    public static void main(String [] args) {
      //  int T = sc.nextInt();while (T--!=0)
        {
            solve();
        }
    }
    public static void solve(){
///////////////////////////////////////////////////////////////////////////////////////////
            int k =sc.nextInt();
            int r =sc.nextInt();
        for (int i = 1; i<(int)1e5 ; i++) {
                if(i*k%10==0){
                    System.out.println(i);
                    return;}
                else if(i*k%10==r){
                    System.out.println(i);
                    return;
            }
        }

////////////////////////////////////////////////////////////////////////////////////////////
    }

}

import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner in=new Scanner(System.in);
        int k=in.nextInt(),r=in.nextInt(),count=1,i=2,p=k;
        while(p%10!=r ){
             if(p%10==r || p%10==0)break;
            p=k*i;
            count++;
            i++;

        }
        System.out.println(count);
    }
}

import java.util.Scanner;

public class BuyaShovel {

	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);

		int k = in.nextInt();
		int r = in.nextInt();
		int an=-1;
		if(k%10==0||k%10==r) {
			an=1;
		}else if(k%10==5&&k>10) {
			an=2;
		}else {
			int[] ar = new int[10];
			int i;
			int d = k%10;

			for(i=1;i<10;i++) {
				int n = i*d;
				int cn = n;
				ar[i]=cn%10;
				if(ar[i]==r||ar[i]==0) {
					an=i;
					break;
				}
			}

		}
		if(an==-1)
			System.out.println(10);
		else
			System.out.println(an);

	}

}

import java.util.*;

public class Solution {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int r = scan.nextInt();
        int kmod = k % 10;
        int result;
        if(kmod == 0) {
            result = 1;
        } else
        if(r % kmod == 0) {
            result = r/ kmod;
        } else
        if(10 % kmod == 0) {
            result = 10/kmod;
        } else {
            result = 1;
            while(((kmod*result) % 10 != r && (kmod*result) % 10 != 0)
 && result < 10) result++;
        }
        System.out.println(result);
    }
}

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		int k = in.nextInt();
		int r = in.nextInt();

		int counter = 0;
		int lastDigit = k % 10;

		if(k == r) {
			System.out.println(1);
			System.exit(0);

		}
		for(int i = 1;  lastDigit != r && lastDigit != 0 ; i++) {

			 lastDigit = (k * i) % 10;

			counter++;

		}
		if(counter == 0) {
			System.out.println(1);
		}else {
		System.out.println(counter);
		}

	}
}

import java.util.Scanner;
public class NewMain {
    public static void main(String[] args){
Scanner f=new Scanner(System.in);
String s=f.nextLine();
  int k=Integer.parseInt(s.substring(0, s.indexOf(" "))),r=Integer.parseInt(s.substring(s.indexOf(" ")+1));
    for(int x=1;x>0;x++)
   if((k*x)%10==0||(k*x)%10==r){
System.out.print(x);
   break;
   }
   }
       }

import java.util.Scanner;
public class Solution{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int r = sc.nextInt();
        for(int i=1 ; i<=9 ; i++){
            if((k*i)%10==0 || (k*i)%10==r){
            System.out.println(i);
            break;}
        }
    }
}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String str1 = input.next();
        String str2 = input.next();
        int k = Integer.parseInt(str1);
        int r = Integer.parseInt(str2);
        int z = k;
        int count = 1;
        int i = 2;
        while(true) {
            if(k%10==r || k%10==0) {
                break;
            }
            else {
                k=z*i;
                count++;
                i++;
            }

        }
        System.out.println(count);
    }
}

import java.util.*;
import java.io.*;

public class shovel{
    public static void main(String args[]){
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

        int cost = in.nextInt();
        int deno = in.nextInt();

        if(cost%10 == 0)
            System.out.println(1);
        else{
            boolean status = true;

            for(int i = 1 ; i < 10 ; i++){
                if(((cost*i)%10 == 0) || (((cost%10)*i)%10 == deno)){
                    System.out.println(i);
                    break;
                }

            }
        }
    }
}

import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt();
        int r = in.nextInt();
        int i = 0;
        while(true){
            i++;
            if(k*i%10 == 0) break;
            else if((k*i-r)%10==0) break;
        }
        System.out.println(i);
    }
}

import java.util.*;
public class den {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int r = sc.nextInt();
		int ans = 999;
		for(int i = 1; i <= 10; ++i)
			if((k*i-r) % 10 == 0 || (k*i) % 10 == 0){
				ans = i;
				break;
			}
		System.out.println(ans);
	}
}

import java.util.*;

public class Shovel
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int p = sc.nextInt();
        int cmp = 1;
        int i = n;
        while((n-p)%10 !=0 &&  (n)%10 !=0)
        {
            n = n + i;
            cmp++;
        }

        System.out.println(cmp);

    }
}

        import java.util.*;
        import java.lang.*;

        public class night
        {
            public static void main(String args[])
            {

    Scanner sc= new Scanner(System.in);
    int n=sc.nextInt();
    int r=sc.nextInt();

    int l=0,z=0;
    for(int i=1;i<=10;i++)
    {
        z=n*i;
        if(z%10==0||z%10==r)
       { System.out.println(i);
       break;
       }

    }

     }
    }

import java.util.*;
public class BuyShovel {

	    public static void main (String [] args){
	        Scanner sc = new Scanner(System.in);
	     int k = sc.nextInt();
	     int r = sc.nextInt();
	    for( int num=1;num <10; num++){
	    	long price= k*num;
	         if (price%10==0 || price%10==r){
	        	 System.out.println(num);
	        //return;
	        	 break;
	    }
	    }

	    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class A {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String[] args) throws Exception {
        FastReader fr = new FastReader();
        int cost = fr.nextInt();
        int change = fr.nextInt();

        int rem = cost%10;
        if(rem==0){
            System.out.println(1);
        }
        else{
            int ans = 1;
            while(rem!=change && rem!=0){
                ans++;
                int val = cost*ans;
                rem = val%10;
            }
            System.out.println(ans);
        }
    }
}

import java.util.Scanner;
import java.util.Arrays;
public class Beginner{
  public static void main(String[]args){
    Scanner m5 = new Scanner(System.in);
    int n=m5.nextInt();
    int m=m5.nextInt();
    int i=1;
	while((n*i%10!=0) && ((n*i-m)%10!=0)) {
		i++;
     }
    System.out.println(i);
  }
}

import java.util.*;
public class Test
{
public static void main(String [] args)
{
int n,r,i,c=1;
Scanner sc =new Scanner(System.in);
n=sc.nextInt();
r=sc.nextInt();
i =n;
while((n-r) %10!=0 && n%10!=0)
{
n=n+i;
c++;
}
System.out.print(c);
}
}

import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split(" ");

		int k = Integer.parseInt(s[0]);
		int r = Integer.parseInt(s[1]);

		int rem = k%10;
		int sum=rem,count=0;

		while(sum!=r && sum!=0)
		{
		    sum=sum+rem;
		    sum=sum%10;
		    count++;
		}

		System.out.println(count+1);
	}
}

import java.util.*;

public class buyashovel {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int r = sc.nextInt();
        int c = 1;
        int x = k;
        while(x%10!=0 && x%10!=r){
            x = x + k;
            c++;
            //if(x/k!=r && c==10){c=0; break;}
            }
         System.out.println(c);
}}

import java.util.Scanner;
public class ProblemCode732a {

    public static void main(String[] args) {
     Scanner s=new Scanner(System.in);
     int r=s.nextInt();
     int k=s.nextInt();
     if(r%10==0 || r%10==k){
     System.out.print("1");
     }
     else{
     for(int i=2;i<10;i++){
     if((r*i)%10==0 || (r*i)%10==k){
         System.out.print(i);
         break;
     }
     }
    }}

}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class C {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int k = sc.nextInt();
        int r = sc.nextInt();

        int ans = 0;
        for(int i = 1; i < 10; i++){

            if (k*i % 10 == 0 || (k*i)%10 == r){
                ans = i;
                break;
            }
        }
        System.out.println(ans);

    }

}

import java.util.Scanner;

/**
 *
 * @author abosala7
 */
public class BuyShovel {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int price = sc.nextInt();
        int den = sc.nextInt();
        int sum  = 0;
        boolean add = true;
        while(add){
            sum += den;
            if (sum % price == 0 ){
                add =false;
                continue;
            }
            sum += 10-den;
            if (sum % price == 0 ){
                add =false;
                continue;
            }
            sum += den;
            if (sum % price == 0 ){
                add =false;
                continue;
            }
            sum -=den;
        }
        System.out.println(sum/price);
    }
}

import java.util.*;
import java.io.*;

public class Main
{

	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);

		int k , r;
		k = sc.nextInt();
		r = sc.nextInt();

		int count = 0;
		long  x = k;
		while(x % 10 != 0  && x % 10 != r){
			count ++;
			x += k;
		}

		System.out.println(count + 1);

		sc.close();
	}

}

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner console = new Scanner(System.in);
        int k = console.nextInt();
        int r = console.nextInt();
        int count = 1;
        int temp = k;
        while (k % 10 != r && k % 10 != 0) {
          k += temp;
          count++;
        }
        System.out.println(count);
    }
  }

import java.util.Scanner;

public class BuyAShovel {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt(); int r = sc.nextInt();
		if(k==r) {
			System.out.println(1);
			return;
		}
		if(k==10+r) {
			System.out.println(1);
			return;
		}
		if(k%10==0) {
			System.out.println(1);
			return;
		}
		if(k%5==0 && k%r!=0) {
			System.out.println(2);
			return;
		}
		int tot = 1;
		while(true) {
			if(((k*tot)-r)%10==0 || (k*tot)%10==0) {
				System.out.println(tot);
				return;
			}
			tot++;
		}

	}

}

import java.util.*;

public class Solution {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int r = scan.nextInt();
        int kmod = k % 10;
        int result;
        if(kmod == 0) {
            result = 1;
        } else
        if(r % kmod == 0) {
            result = r/ kmod;
        } else
        if(10 % kmod == 0) {
            result = 10/kmod;
        } else {
            result = 1;
            while(((kmod*result) % 10 != r && (kmod*result) % 10 != 0)
 && result < 10) result++;
        }
        System.out.println(result);
    }
}

import java.util.Scanner;
//import java.lang.Math;

public class buy_a_shovel {
    public static void main(String[] args) {
        solve();
    }

    static void solve() {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int r = sc.nextInt();
        int shovels = 1;
        while (true) {
            if ((shovels*k % 10 == r) || (shovels*k % 10 == 0)) {
                break;
            }
            shovels++;
        }
        System.out.println(shovels);
        sc.close();
    }
}

import java.io.*;

public class shovel{
  public static void main(String[] args) throws IOException {
    BufferedReader scan= new BufferedReader(new InputStreamReader(System.in));
    String[] str= scan.readLine().split(" ");
    int price= Integer.parseInt(str[0]);
    int change= Integer.parseInt(str[1]);
    int temp1=0;
    int temp2=0;
    int temp=0;
    for(int i=1; i<10; i++){
      temp1=i*price;
      temp2=temp1-change;
      if(temp1%10==0 || temp2%10==0){
        temp=i;
        break;
      }
    }
    System.out.println(temp);
  }
}

import java.util.*;
public class BuyaShovel {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);

		//input the price
		int price = scan.nextInt();

		//input the coin
		int coin = scan.nextInt();

		//the quantity is initially 1 because it's the min
		int quantity = 1 ;

		while((price*quantity)%10!=0 && (price*quantity-coin)%10!=0){
			quantity++;
		}
		System.out.println(quantity);

	}

}

import java.io.*;
import java.util.StringTokenizer;

public class Buy_a_Shovel {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		//PrintWriter out = new PrintWriter(System.out);

		double x = Integer.parseInt(st.nextToken());
		double y = Integer.parseInt(st.nextToken());

		int num = 1;
		double sum1 = (num*10 + y)/x;
		double sum2 = (num*10 )/x;
		double sum3 = ( y )/x;
		if (sum3 %1 == 0.0 ){
				System.out.println((int)sum3);
				return;}
		while (num < x){
			 if (sum1%1 == 0.0){
				System.out.println((int)sum1);
				return;}
			else if (sum2%1 == 0.0){
				System.out.println((int)sum2);
				return;}
			num++;
			 sum1 = (num*10 + y)/x;
			 sum2 = (num*10 )/x;
		}

	}

}

import java.util.*;
public class Main
{
	public static void main(String[] args) {
		int k,r,ans=0;

		Scanner sc=new Scanner(System.in);
		k=sc.nextInt();
		r=sc.nextInt();
		int f=k%10,i=1;
		while((f*i)%10!=r)
		{
		    if((f*i)%10==0)
		    break;
		    i++;
		}

		System.out.println(i);
	}
}

import java.util.Scanner;
public class buyashovel {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		int r = scan.nextInt();
		boolean bol = true;
		for (int i = 1 ; i <=10 && bol ; i++) {
			if ((i*k)%10==0) {
				System.out.println(i);
				bol=false;
			}
			else if (((i*k)-r)%10==0) {
				System.out.println(i);
				bol=false;
			}
		}
	}
}

import java.util.*;
public class Main {

    public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	int k=sc.nextInt();
	int r=sc.nextInt();
	int q=0;
	int z=0;

            for (int i = 1; i <= 9; i++)
            {
                        q = k * i;
                        z = q % 10;
                        if(z==0) {
                            System.out.println(i);
                            break;
                        }
                        else if (z == r) {
                            System.out.println(i);
                            break;
                        }
                        else {
                            continue;
                        }
                    }
                }
        }

import java.util.*;public class div2_377A {public static void main(String args[]){Scanner sc = new Scanner(System.in);int k = sc.nextInt();int r = sc.nextInt();if(k%10==0){System.out.println(1);}else if((k-r)%10==0){System.out.println(1);}else if(k%5==0){System.out.println(2);}else if(k%2==0&&r%2!=0){System.out.println(5);}else{for(int i=0;i<10;i++){if((k*i)%10==r){System.out.println(i);break;}}}}}

import java.util.*;
public class den {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int r = sc.nextInt();
		int ans = 999;
		for(int i = 1; i <= 10; ++i){
			if((k*i-r) % 10 == 0){
				ans = i;
				break;
			}
		}
		for(int i = 1; i <= 10; ++i){
			if((k*i % 10 == 0)){
				if(i < ans){
					ans = i;
					break;
				}
			}
		}
		System.out.println(ans);
	}
}

import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int number=sc.nextInt();
		int num=sc.nextInt();
		int i=1;
		while ((((number*i)%10)!=num)&(((number*i)%10)!=0)){
			i++;
		}
		System.out.println(i);
	}
}

import java.util.*;
import java.lang.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int r = scan.nextInt();
        int count = 0;
        int i =1;
        while (true){
            if(((k*i)-r)%10==0 || (k*i)%10 == 0){
                count = i;
                break;
            }
            i++;
        }
        System.out.println(count);
    }
}

import java.util.*;

public class Main{

     public static void main(String []args){

        Scanner scc =new Scanner(System.in);
        int n=scc.nextInt();
        int k=scc.nextInt();

        int d=n%10;
        int i=1;
        while(true){
            if((d*i)%10==k||(d*i)%10==0)
            break;
            i++;
        }

        System.out.println(i);

     }
}

import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int k = in.nextInt();

        for (int i = 1 ; i <= 10 ; ++i){
            if ((n * i) % 10 == 0 || (n * i) % 10 == k)
            {
                System.out.println(i);
                return;
            }
        }
    }
}

import java.util.Scanner;
import java.util.Arrays;
public class Beginner{
  public static void main(String[]args){
    Scanner m5 = new Scanner(System.in);
    int n=m5.nextInt();
    int m=m5.nextInt();
    int i=1;
	while((n*i%10!=0) && ((n*i-m)%10!=0)) {
		i++;
     }
    System.out.println(i);
  }
}

import java.util.Scanner;
public class Shovel {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int shovelPrice = sc.nextInt();
		int coinVal = sc.nextInt();
		int i = 1;
		int numShovels=0;
		while(true) {
			int price = shovelPrice * i;
			if(price%10 == coinVal || price%10==0) {
				numShovels=i;
				break;
			}
			i++;
		}
		System.out.println(numShovels);
	}

}

import java.util.Scanner;

/*
 * @author abosala7
 */
public class BuyShovel {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int price = sc.nextInt();
        int change = sc.nextInt() ;
        System.out.println(numOfShovel(price,change));
    }
        public static int numOfShovel(int price, int change){
            int sum = price ;
            while(true){
                if((sum % 10 == 0)||(sum % 10 == change)){
                    break;
                }
                sum += price ;
            }
            return (sum/price) ;
        }
}

import java.util.*;
public class HelloWorld {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		int k=s.nextInt();
		int r=s.nextInt();
		int i=1;
		while(true) {
			if(i*k%10==0 || ((i*k)-r)%10==0)
			{
				System.out.print(i);
				break;
			}
			i++;
		}
	}
}

import java.util.Random;
import java.util.ArrayList;
import java.util.Scanner;
import java.lang.Math;
import static java.lang.Math.abs;
/**
 *
 * @author LOL
 */
public class JavaApplication8 {

    /**
     * @param args the command line arguments
     */
    public static int function_comp(int x , int y){
        if(x>y)
            return x;
        return y;

    }
        public static int function_comp_min(int x , int y){
        if(x<y)
            return x;
        return y;

    }
        public static int get_last(int M)
        {
            if(M<10 && M > -10)
            {
                return M;
            }

            return M%10;

        }
    public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int K = input.nextInt();
int R = input.nextInt();
int last= get_last(K);

if(last==R)
    System.out.println(1);
else
{int result=0;
int i=1;
int n=10000;
int min=0;
int x=0;
boolean check =false;
    while(i<10)
    {
        result=last*i;
        if(get_last(result)==0)
        {

            n = function_comp_min(n,i);
            x=i;

        }
        if(get_last(result)==R)
        {
            System.out.println(i);

            break;
        }

        i++;

    }
     if(n==R){
            System.out.println(n);
            }

}

    }

}

import java.io.*;
import java.util.*;

public class Main {

    public static void main(String [] args){
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Integer readFromFile=new Integer(1);
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskD {

        class Pair{
            int first;
            int second;
            Pair(int first, int second){
                this.first = first;
                this.second = second;
            }
            Pair(){}
        }
        class Comp implements Comparator<Integer>{
            @Override
            public int compare(Integer o1, Integer o2) {
                return (o1-o2)*-1;
            }
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int one = in.nextInt();
            int oct = n%10;
            if(oct==0 || oct%one==0){
                out.println("1");
                return;
            }
            int sum = 0;
            for(int i=1; i<=10; i++){
                if((((oct*i)%10)-one==0) || (oct*i)%10==0){
                    out.println(i);
                    break;
                }
            }
        }
    }
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;
        String st1;
        File file = new File("text.txt");
        public InputReader(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
            st = null;
        }
        public InputReader(int i) {
            try {
                br  = new BufferedReader(
                        new InputStreamReader(new FileInputStream(file)));
            } catch (FileNotFoundException e1) {
                System.out.println("File is not find");
            }
            st = null;
        }
        public String next(){
            while (st==null || !st.hasMoreTokens()){
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public String nextLine(){
            try {
                st1 = new String(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return st1;
        }
        public int nextInt()  {return Integer.parseInt(next());}
        public long nextLong(){
            return Long.parseLong(next());
        }
        public Double nextDouble(){
            return Double.parseDouble(next());
        }
        public Byte nextByte() {
            return Byte.parseByte(next());
        }
        private int idx;
        public Character nextChar() {
            if(st1==null) {
                st1 = next();
                idx = 0;
            }
            if(idx!=(st1.length())-1){
                return st1.charAt(idx++);
            }else{
                char  c= st1.charAt(idx);
                st1 = null;
                return c;
            }
        }
        public void newFile() {
            try {
                FileWriter write = new FileWriter(file);
                write.write("something for cheaking");
                write.close();

            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

import java.util.Scanner;
public class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        int cost=scan.nextInt();
        int singlew=scan.nextInt();

        int no=0;

        if(cost%10==0){
            System.out.println("1");
        }
        else if(cost==1){
            if(cost<=singlew){
                no=singlew;
                System.out.println(no);
            }
            else{
                System.out.println("10");
            }
        }

        else{
            if((cost%10)%singlew==0){
                System.out.println("1");
            }
            else if(cost%5==0){
                System.out.println("2");
            }
            else {
                while(((7*no)%10)-singlew!=0){
                    no++;
                }
                System.out.println(no);
            }
        }
    }
}

import java.util.Scanner;

/**
 *
 * @author ahmed sabrey
 */
public class JavaApplication74 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in = new Scanner(System.in);

        int k = in.nextInt();
        int r = in.nextInt();
        int t;
        for (int i = 1;  i<=1000000; i++){
             t =k* i;
             if (t%10 == r){
                 System.out.println(i);
                 break;
             }
                 else  if (t%10 == 0){
                 System.out.println(r);
                 break;}

             }

        }

    }

import java.util.Scanner;

public class BuyAShovel {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int r = sc.nextInt();
    int temp = k;
    int count = 1;
    int count1 = (k/10)+1;
    while(k%10 != r && count < count1) {
      k += temp;
      count++;
    }
    System.out.println(Math.min(count, count1));
    sc.close();
  }
}

import java.util.*;

public class cf {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int p = sc.nextInt();
    int c = sc.nextInt();
    int res = 0;
    int ones = p%10;
    int o = p;

    if(ones == 0){
      res = 1;
      p = 0;
    }
    else if(ones == 2){
      res = 1;
      p = 0;
    }
    else if(ones == 5){
      res = 1;
      p = 0;
    }

    while(p > 0){
      ones = p%10;
      if(ones == c){
        p -= c;
        ++res;
        p = 0;
      }
      else{
        p += o;
        ++res;
      }
    }

    System.out.println(res);
  }
}

import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int c = 1;
	    int k = sc.nextInt();
	    int a = k;
	    int r = sc.nextInt();
	    if(k%10 == 0){
	       System.out.println(k/10);
	    }
	    else if(k%5 == 0){
	        System.out.println(k/10+1);

	    }
        else{
        while(k%10!=r){
            k+=a;
            c++;
        }
        System.out.println(c);
        }
	}
}

import java.util.*;
public class HelloWorld {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		int k=s.nextInt();
		int r=s.nextInt();
		if(k<10)
			System.out.print(r);
		else {
		int d=k/10;
		int r1=k%10;
		if(r1==r)
		System.out.print("1");
		else {
			r1=Math.abs(r1-r);
			int ans=Math.abs(d-(r1-1));
			System.out.print(ans+1);
		}}

	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

/**
 *
 * @author ONE BY ONE
 */
public class ABuyAShovel {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
       Scanner s=new Scanner(System.in);
        int a = s.nextInt();
        int b= s.nextInt();
        int sum=0;int count=0;
      int t=0;
        if(a>=1&&a<=9){
            System.out.println(a);
            return;
        }

        while(count>=0 &&count<=1000) {

    t++;
    sum+=a;

    if((sum)%(10)==b){
        System.out.println(t);return;
    }

    if(sum%10==0){
            System.out.println(t);return;}

          count++;

      }

    }

}

import java.io.*;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.Scanner;
public class shovel2
{
	public static void main(String[] args) throws IOException
	{
		int k;
		int r;
		Scanner sc=new Scanner(System.in);
		k=sc.nextInt();
		r=sc.nextInt();
		//int k=1;
		int arr[]=new int[9];
		int b[]=new int[9];
		int q=1;
		for(int i=0;i<9;i++)
		{
			arr[i]=q*k;
            b[i]=arr[i]%10;
            q++;
		}
		/*for(int i=0;i<9;i++)
		{
			System.out.print(arr[i]+" ");
		}*/
		/*System.out.println();
		for(int i=0;i<9;i++)
		{
			System.out.println(b[i]+" ");
		}*/
		if(k%10!=5 && k%10!=0)
       {
		for(int i=0;i<9;i++)
		{
			if(b[i]==r)
			{
				int j=i+1;
				System.out.println(j);
				break;
			}
       }
	     }
	if(k%10==5 && r!=5)
	{
		int u=2;
		System.out.println(u);
	}
	if(k%10==5 && r==5)
	{
		int n=1;
		System.out.println(n);
	}
	 if(k%10==0)
	{
		int e=0;
		System.out.println(e);
	}
	}
}

import java.util.*;
public class div2_377A {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int r = sc.nextInt();
		if(k%10==0){
			System.out.println(1);
		}else if((k-r)%10==0){
			System.out.println(1);
		}else if(k%5==0){
			System.out.println(2);
		}else{
			for(int i=2;i<10;i++){
				if((k*i)%10==r){
					System.out.println(i);
					break;
				}
			}
		}
	}

}

import java.util.Scanner;

public class BuyAShovel {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int r = sc.nextInt();
    int temp = k;
    int count = 1;
    int count1 = k<r ? 10-k : (k/10)+1;
    if(k<r && r%k==0) {
        count = r/k;
    } else {
      while(k%10 != r && count < count1) {
        k += temp;
        count++;
      }
    }
    System.out.println(Math.min(count, count1));
    sc.close();
  }
}

import java.util.*;

public class Solution{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int k = sc.nextInt();
        int r = sc.nextInt();

        if(k==r || k%10 == 0){
            System.out.println("1");
        }
        else{
            int shovels = 1;
            int multiplier = k/10;
            int amount = 10*multiplier;

            if(shovels < 10){
                while((amount+r) != k*shovels){
                    shovels++;
                    multiplier = (k*shovels-amount)/10;
                    amount += 10*multiplier;
                }
            }

            if(amount == k*shovels){
                System.out.println(shovels);
            }
            else{
                System.out.println("10");
            }
        }
    }
}

import java.util.Scanner;
public class Problemcose732A {

    public static void main(String[] args) {
       Scanner s=new Scanner(System.in);

       int x,b;
       int k=s.nextInt();
       int r=s.nextInt();

       if(k%10 ==0|| k%10==r){
       System.out.print("1");
       }
       else
           for (int i=2;i<10;i++){

        if(k*i%10 ==0|| k*i%10==r)
            System.out.print(i);
       }}

    }

import java.util.Scanner;

/**
 * Created by Kamal on 26-10-2016.
 */
public class BuyAShovel
{
    private static int k;
    private static int r;

    public static int getK() {
        return k;
    }

    public static void setK(int k) {
        BuyAShovel.k = k;
    }

    public static int getR() {
        return r;
    }

    public static void setR(int r) {
        BuyAShovel.r = r;
    }

    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);

        k = scanner.nextInt();
        r = scanner.nextInt();

        System.out.println(findMinimum());
    }

    public static int getLast (int number)
    {
        return number %  10;
    }

    public static int findMinimum ()
    {
        if (k == 2 )
            return 5;
        for (int counter = 0; counter <= k; counter++)
        {
            int totalPrice = getTotalPrice(counter);

            int lastDigit = getLast(totalPrice);

            if (lastDigit == r)
                return counter;
        }

        for (int counter = 1; counter <= k; counter++)
        {
            int totalPrice = getTotalPrice(counter);

            int lastDigit = getLast(totalPrice);

            if (lastDigit == 0)
                return counter;
        }

        return r;
    }

    public static int getTotalPrice (int n)
    {
        return n * k;
    }

}

import java.io.*;
import java.util.StringTokenizer;
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tk=new StringTokenizer(bf.readLine());
        int a=Integer.parseInt(tk.nextToken());
        int b=Integer.parseInt(tk.nextToken());
        int i=1;
        int temp=-2;
        while(temp%10!=0 && (temp-b)%10!=0){
        temp=i*a;
        i++;
        }
        int res=i-1;
        PrintWriter pw=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        pw.write(((res==0)?1:res)+"\n");
        pw.flush();
    }}

import java.util.Scanner;

/**
 * Created by Kamal on 26-10-2016.
 */
public class BuyAShovel
{
    private static int k;
    private static int r;

    public static int getK() {
        return k;
    }

    public static void setK(int k) {
        BuyAShovel.k = k;
    }

    public static int getR() {
        return r;
    }

    public static void setR(int r) {
        BuyAShovel.r = r;
    }

    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);

        k = scanner.nextInt();
        r = scanner.nextInt();

        System.out.println(findMinimum());
    }

    public static int getLast (int number)
    {
        return number %  10;
    }

    public static int findMinimum ()
    {
        if (k == 2 && r == 3)
            return r;
        for (int counter = 0; counter <= k; counter++)
        {
            int totalPrice = getTotalPrice(counter);

            int lastDigit = getLast(totalPrice);

            if (lastDigit == r)
                return counter;
        }

        for (int counter = 1; counter <= k; counter++)
        {
            int totalPrice = getTotalPrice(counter);

            int lastDigit = getLast(totalPrice);

            if (lastDigit == 0)
                return counter;
        }

        return r;
    }

    public static int getTotalPrice (int n)
    {
        return n * k;
    }

}

import java.util.Scanner;

public class BuyaShovel {

	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);

		int k = in.nextInt();
		int r = in.nextInt();
		int an=-1;
		if(k%10==0) {
			an=1;
		}else if(k%10==5&&k>10) {
			an=2;
		}else {
			int[] ar = new int[10];
			int i;
			int d = k%10;

			for(i=1;i<10;i++) {
				int n = i*d;
				int cn = n;
				ar[i]=cn%10;
				if(ar[i]==r||ar[i]==0) {
					an=i;
					break;
				}
			}

		}
		if(an==-1)
			System.out.println(10);
		else
			System.out.println(an);

	}

}

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner kb = new Scanner(System.in);
        int K = kb.nextInt();
        int R = kb.nextInt();
        int m = 10;
        for(int i = 1; i <= 10; i++) {
            int c = i*K;
            if(c%10== R || c%10 == 0) {
                m = R;
                break;
            }
        }
        System.out.println(m);
    }
}

import java.util.*;

public class shovel{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);

        int cost = in.nextInt();
        int deno = in.nextInt();

        if(cost == 5)
            System.out.println(1);
        if(cost%10 == 0)
            System.out.println(1);
        else
        if(cost%5 == 0)
            System.out.println(2);
        else{
            int x = cost % 10;
            boolean flag = false;
            for(int i = 1 ; i < 10 ; i++){
                if((x*i)%10 == deno){
                    System.out.println(i);
                    flag = true;
                    break;
                }

            }

            if((flag == false) && (x % 2 == 0))
                System.out.println(5);
            else
            if((flag == false) && (x % 2 != 0))
                System.out.println(10);

        }
    }
}

//Written by Shagoto
import java.util.*;
public class Main
{
  public static void main(String[]args)
  {
    Scanner read = new Scanner(System.in);

    int k = read.nextInt();
    int r = read.nextInt();

    if(k < 10)
    {
      if(r == k)
      {
        System.out.println(1);
      }
      else if(r > k)
      {
        System.out.println(r);
      }
      else
      {
        int t = 1;
        while(true)
        {
          if((10*t + r) % k == 0)
          {
            System.out.println((10*t + r) / k);
            break;
          }
          else
          {
            t++;
          }
        }
      }
    }

    else
    {
      int t = 1;
      while(true)
      {
        if((10*t) % k == 0)
        {
          System.out.println((10*t) / k);
          break;
        }
        else if((10*t + r) % k == 0)
        {
          System.out.println((10*t + r) / k);
          break;
        }
        else
        {
          t++;
        }
      }
    }
  }
}

import java.util.Scanner;

public class A732 {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int r = sc.nextInt();
        int n = 10;
        if(k%10 == 0){
            System.out.println(1);
        }else if(k == 1){System.out.println(r);}
        else if(k%5 == 0 && r == 5){System.out.println(k/10);}
        else if(k%5 == 0){
            System.out.println(2);
        }else if((k*5)%10 == 0){System.out.println(5);}
        else{
        while((n+r)%k != 0){
            n+= 10;
        }
        System.out.println((n + r)/k);}
    }
}

import java.io.*;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.Scanner;
public class shovel2
{
	public static void main(String[] args) throws IOException
	{
		int k;
		int r;
		Scanner sc=new Scanner(System.in);
		k=sc.nextInt();
		r=sc.nextInt();
		//int k=1;
		int arr[]=new int[9];
		int b[]=new int[9];
		int q=1;
		for(int i=0;i<9;i++)
		{
			arr[i]=q*k;
            b[i]=arr[i]%10;
            q++;
		}
		/*for(int i=0;i<9;i++)
		{
			System.out.print(arr[i]+" ");
		}*/
		/*System.out.println();
		for(int i=0;i<9;i++)
		{
			System.out.println(b[i]+" ");
		}*/
		if(k%10!=5 && k%10!=0)
       {
		for(int i=0;i<9;i++)
		{
			if(b[i]==r)
			{
				int j=i+1;
				System.out.println(j);
				break;
			}
       }
	     }
	if(k%10==5 && r!=5)
	{
		int u=2;
		System.out.println(u);
	}
	if(k%10==5 && r==5)
	{
	   int z=1;
	   System.out.println(z);
	}
	/*/else
	{
		int x=1;
		System.out.println(x);
	}*/

	 if(k%10==0)
	{
		int e=0;
		System.out.println(e);
	}
	}
}

import java.util.*;
public class buy_a_shovel
{
    public static void main(String [] args)
    {
        Scanner sc=new Scanner(System.in);
        int k=sc.nextInt();
        int r=sc.nextInt();
        int i=k%10;;
        if(i==r||i==0)
        {
        System.out.println("1");
        }
        if(i!=0||i!=r&&k!=1000)
        {
            for(int ii=2;ii<10;ii++)
            {
                int rem=(i*ii)%10;
                if(rem==0||rem==r)
                {
                System.out.println(ii);
                break;
                }
            }

        }

    }
}

import java.util.Scanner;
public class Sh{
public static void main (String[] args) {
Scanner sc=new Scanner(System.in);
int k=sc.nextInt();
int r=sc.nextInt();
if(k<r) System.out.println(0);
if (k==r || k==10) System.out.println(1);
if(k>10){
int sum=10;
int n=1 ;
while(((sum+r)%k)!=0 && sum!=k*10){
sum+=10;

}
if(sum==k*10) System.out.println(10);
if (sum!=k*10) System.out.println((sum+r)/k);
}}}

import java.util.*;

public class Solution {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int r = scan.nextInt();
        int kmod = k % 10;
        int result;
        if(kmod == 0) {
            result = 1;
        } else
        if(r % kmod == 0) {
            result = r/ kmod;
        } else
        if(10 % kmod == 0) {
            result = 10/kmod;
        } else {
            result = 1;
            while(r*result % kmod == 0 && result < 10) result++;
        }
        System.out.println(result);
    }
}

//BufferedReader + StringTokenizer
//ArrayList for arrays in Java

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class solve {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(in, out);
		out.close();
	}

	static class Task {
		public void solve(InputReader in, PrintWriter out) {
			int k = in.nextInt();
			int r = in.nextInt();
			int summ = 0, answer = -1;
			for (int i = 0; i < 9; i++) {
				summ += k;
				if (answer != -1 && summ % 10 == r || summ % 10 == 0) answer = i + 1;
			}
			if (answer != -1) out.println(answer);
			else out.println("10");
		}
	}

	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
		public double nextDouble() {
            return Double.parseDouble(next());
        }

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out=new PrintWriter(System.out);

        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int k=Integer.parseInt(st.nextToken());

        int r=Integer.parseInt(st.nextToken());
        if(k<10&&k!=r)
            out.println(0);
        else {
            if (k % 10 == 0)
                out.println(1);
            else {

                int u = k % 10;
                if (u == 5 && r != 5)
                    out.println(2);
                else {
                    int i;
                    for (i = 1; i < 10; i++) {
                        if ((i * u) % 10 == r) {
                            out.println(i);
                            break;
                        }

                    }

                    if (i == 10)
                        out.println(10);
                }
            }
        }
        out.flush();

    }
}

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner scan =new Scanner(System.in);
		int k = scan.nextInt();
		k = k % 10;

		int r = scan.nextInt();
		int returnValue=0;
		int count=1;

		if(k%10 == 0 || k==r)
			returnValue=1;
		else if(k==5)
			returnValue=2;
		else if(r>k && r%k ==0)
			returnValue=r/k;
		else
		{
			while(k!=r && count < 10)
			{
				k= k - r;
				count++;
				if(k<0)
					k = 10 + k;
			}

		returnValue=count;
		}

		System.out.println(returnValue);
	}
}

/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
	    Scanner in=new Scanner(System.in);
	    int k=in.nextInt(); k=k%10;
	    int r=in.nextInt();
	    int c=0;int i=k;
        while(true)
	    {
	        c++;
	        i=i+k;
	        i=i%10;
	        if(i!=r || i==k)
	        break;

	    }

	    System.out.println(c+1);
	}
}

import java.util.Scanner;

public class BuyAShovel {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt(); int r = sc.nextInt();
		if(k%5==0) {
			System.out.println(2);
			return;
		}
		if(k%10==0) {
			System.out.println(1);
			return;
		}
		//int x = 10+r;
		int tot = 10+r;
		while(tot%k!=0) {
			tot+=10;
		}
		System.out.println(tot/k);

	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Admin
 */
public class A732 {

    static BufferedReader br = new BufferedReader(new InputStreamReader(
            System.in));

    static long getInt() throws Exception {
        long n = Long.parseLong(br.readLine());
        return n;
    }

    static int[] getIntarr() throws Exception {
        String arr[] = br.readLine().split(" ");
        int a[] = new int[arr.length];
        for (int i = 0; i < a.length; i++) {
            a[i] = Integer.parseInt(arr[i]);
        }
        return a;
    }

    public static void main(String[] args) throws IOException, Exception {
        int y[] = getIntarr();
        int k = y[0];
        int r = y[1];
        int only10 = k;
        int tenr = 0;
        int i = 1;
        while (true) {
            if (only10 % 10 != 0) {
                only10 = k * i;

            } else {
                break;
            }
            i++;
        }
        int j = 1;
        tenr = k;

        while (true) {
            if(tenr % 10 != 3){
            tenr = k * j;
            }else{
                break;
            }
            j++;
        }
        if (only10 > tenr) {
            System.out.println(j-1);
        } else {
            System.out.println(i-1);
        }
    }
}

import java.util.*;
public class Main{

     public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int r = sc.nextInt();
        int res=1;
        if(k%10 == 0 || (k-r)%10 ==0)
        {
            System.out.println("1");
            return;
        }
        if(k%5 == 0)
        {
            System.out.println("2");
            return;
        }
        if(r>k && r%k == 0)
        {
            System.out.println(r/k);
            return;
        }
        while(k % 10 !=0)
        {
            k = res*k - r;
            res++;
        }
        System.out.println(res+1);

     }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Shovels {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		StringTokenizer st=new StringTokenizer(s);
		int price=Integer.parseInt(st.nextToken());
		int coin=Integer.parseInt(st.nextToken());
		int total=0;
		for(int i=0;i<price;i++) {
			total=total+10;
			if((total%price)==0) {
				System.out.print(total/price);
				return;
			}

				if((total+coin)%price==0) {
					System.out.print((total+coin)/price);
					return;
				}

		}
	}

}

import java.util.Scanner;

/**
 * https://codeforces.com/problemset/problem/732/A
 */
public class Problem732A {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        scanner.useDelimiter(System.lineSeparator());
        String[] input = scanner.next().split(" ");
        scanner.close();

        int shovelCost = Integer.parseInt(input[0]);
        int coinValue = Integer.parseInt(input[1]);
        int result = 0;

        if (shovelCost == coinValue) {
            result++;
        } else if (shovelCost <= 9 && coinValue % shovelCost == 0) {
            result = coinValue / shovelCost;
        } else if (shovelCost % 10 == 0) {
            result++;
        } else {
            int wasted = 0;
            if (shovelCost < 10) {
                while (wasted <= 10) {
                    wasted += shovelCost;
                    result++;
                }
            }
            if (wasted != 10) {
                do {
                    wasted += shovelCost;
                    if (wasted % 10 == coinValue || wasted % 10 == 0) {
                        result++;
                        break;
                    }
                    result++;
                } while (true);
            }
        }

        System.out.println(result);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class BuyAShovel {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Solution sol = new Solution();
		sol.solve(in, out);
		out.close();
	}

	private static class Solution {
		private void solve(InputReader in, PrintWriter out) {
			int k=in.ni(), r=in.ni();
			for (int i=1; i<=10; ++i) {
				if ((k*i)%10==r) {
					out.println(i);
					return;
				}
			}
			out.println(10);
		}
	}

	private static class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		private InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		private String n() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		private int ni() {
			return Integer.parseInt(n());
		}

		private long nl() {
			return Long.parseLong(n());
		}

		private int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; ++i)
				a[i] = ni();
			return a;
		}
	}

}

import java.util.Scanner;

public class Buy_A_Shovel {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		int  k = sc.nextInt();
		int  r = sc.nextInt();

		if(k%10==5) {
			System.out.println("2");
			return;
		}
		if(k%10==0) {
			System.out.println("1");
			return;
		}
		int i =1 ;
		long temp=k;
		while(i<=1000) {
			temp=k*i;
			if(temp%10==r) {
				System.out.println(i);
				return;
			}
			i++;
		}
		System.out.println(1);
	}

}

import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

public class Solution {
    public static void main(String[] args){
        Scanner sn = new Scanner (System.in);
        int price = sn.nextInt();
        int cha = sn.nextInt();
        int x=1;
        while(price%10!=0 && price%10!=cha ){
            x++;
            price*=x;

        }
        System.out.print(x);

    }
}

import java.io.*;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.Scanner;
public class shovel2
{
	public static void main(String[] args) throws IOException
	{
		int k;
		int r;
		Scanner sc=new Scanner(System.in);
		k=sc.nextInt();
		r=sc.nextInt();
		//int k=1;
		int arr[]=new int[9];
		int b[]=new int[9];
		int q=1;
		for(int i=0;i<9;i++)
		{
			arr[i]=q*k;
            b[i]=arr[i]%10;
            q++;
		}

		if(k%10!=5 && k%10!=0)
       {
		for(int i=0;i<9;i++)
		  {
			if(b[i]==r)
			{
				int j=i+1;
				System.out.println(j);
				break;
			}
          }
	  }
	if(k%10==5 && r!=5)
	{
		int u=2;
		System.out.println(u);
	}
	if(k%10==5 && r==5)
	{
	   int z=1;
	   System.out.println(z);
	}
	 if(k%10==0)
	{
		int e=10;
		System.out.println(10);
	}
  }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.StringTokenizer;

public class A {
    void solve() {
        FastReader sc = new FastReader();
        int p = sc.nextInt();
        int k = sc.nextInt();
        int a = 0;
        if (p < k) {
            a = k;
        } else if (p % k == 0) {
            p = p / k;
            a = p % 10;
        } else {
            p = p % 10;
            a = p / k;
        }
        System.out.println(a);
    }

    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        new A().solve();
    }

    class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }
    }
}

import java.util.Scanner;
public class Sh{
public static void main (String[] args) {
Scanner sc=new Scanner(System.in);
int k=sc.nextInt();
int r=sc.nextInt();
if(k<r) System.out.println(0);
if (k==r || k==10) System.out.println(1);
if(k>10){
int sum=10;
int n=1 ;
while(((sum+r)%k)!=0 && sum!=k*10 && sum%k==0){
sum+=10;

}
if(sum==k*10) System.out.println(10);
if (sum!=k*10) System.out.println((sum+r)/k);
}}}

import java.io.*;

import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class apples{

    public static void main(String[] args) {

    	Scanner zizo=new Scanner(System.in);
    	int k=zizo.nextInt();
    	int r=zizo.nextInt();
    	int x=r;
    	int c=0;
    	while(x!=k) {
    		if(x==k)
    			break;
    		x+=10;
    		c+=1;
    	}

    	System.out.println(c);
    	}

    }

import java.util.*;
public class BuyShovel {

       public static void main (String [] args) throws Exception {
           Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int r = sc.nextInt();
        int num=1;
        int count=0;
        int total = k *num;
     //   while(total!=0){
            if (total%10==0 || total%r==0){
                count ++;
                num++;
        }
       // }
        System.out.println(" the min. no. is " + count);
           }
       }

import java.util.Scanner;
public class buyashovel {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		int r = scan.nextInt();
		if (r == k) {
			System.out.println("1");
		}
		else if (k == 1) {
			System.out.println(r);
		}
		else {
			boolean bol = true;
			for (int i = 10 ; bol ; i+=10) {
				if (i%k==0) {
					System.out.println(i/k);
					bol = false;
				}
				else if ((i+r) % k == 0) {
					System.out.println((i+r)/k);
					bol = false;
				}
			}
		}
	}
}

import java.util.*;
public class Acm {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k=sc.nextInt();
        int r=sc.nextInt();
        int count=0;
        if(k==10||(k<10&&k==r)){
            System.out.println("1");
            System.exit(0);
        }
        else if(k<10&&k<=r)
        {
        if(r%k==0)
        {
        System.out.println(r/k);
            System.exit(0);
        }

        }
        else
        {
        for(int i=1;i<=10000;i++)
        {
         if((10*i)%k==0)
         {
         count=(10*i)/k;
            System.out.println(count);
            System.exit(0);
         }
         else{
        if(((10*i)+r)%k==0){
            count=((10*i)+r)/k;
            System.out.println(count);
            System.exit(0);
        }
         }
        }
         System.out.println("0");
        }
}
}

import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.lang.Character;

public class Main {

    static void addElementToHashMap(HashMap<Integer, Integer> map, int element)
    {
        if (map.containsKey(element)) {
            map.put(element, map.get(element) + 1);
        }
        else {
            map.put(element, 1);
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String[] line = in.nextLine().split(" ");
        int k = Integer.parseInt(line[0]);
        int r = Integer.parseInt(line[1]);

        int current = 10;

        int shovels;

        if (k % 10 == 0) shovels = 1;

        else {
            while((current + r) % k != 0 && (current % k != 0))
            {
                current += 10;
            }

            shovels = (current + r) / k;
        }

        System.out.println(shovels);
    }
}

import java.io.*;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.Scanner;
public class shovel2
{
	public static void main(String[] args) throws IOException
	{
		int k;
		int r;
		Scanner sc=new Scanner(System.in);
		k=sc.nextInt();
		r=sc.nextInt();
		//int k=1;
		int arr[]=new int[9];
		int b[]=new int[9];
		int q=1;
		for(int i=0;i<9;i++)
		{
			arr[i]=q*k;
            b[i]=arr[i]%10;
            q++;
		}
		/*for(int i=0;i<9;i++)
		{
			System.out.print(arr[i]+" ");
		}*/
		/*System.out.println();
		for(int i=0;i<9;i++)
		{
			System.out.println(b[i]+" ");
		}*/
		if(k%10!=5 && k%10!=0)
		{
		for(int i=0;i<9;i++)
		{
			if(b[i]==r)
			{
				int j=i+1;
				System.out.println(j);
				break;
			}
		}
	}
	/*else if(k%10==5)
	{
		int u=2;
		System.out.println(u);
	}
	else if(k%10==0)
	{
		int e=0;
		System.out.println(e);
	}*/
	}
}

import java.util.*;

public class shovel{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);

        int cost = in.nextInt();
        int deno = in.nextInt();

        if(cost == 5)
            System.out.println(1);
        else
        if(cost%10 == 0)
            System.out.println(1);
        else
        if(cost%5 == 0)
            System.out.println(2);
        else{
            int x = cost % 10;
            boolean flag = false;
            for(int i = 1 ; i < 10 ; i++){
                if((x*i)%10 == deno){
                    System.out.println(i);
                    flag = true;
                    break;
                }

            }

            if((flag == false) && (x % 2 == 0))
                System.out.println(5);
            else
            if((flag == false) && (x % 2 != 0))
                System.out.println(10);

        }
    }
}

import java.util.Scanner;
public class BuyAShovel {

	public static void main(String[] args) {
		Scanner in = new Scanner (System.in);

		short k = in.nextShort();
		byte r = in.nextByte();
		int sum = (int)(10 * Math.ceil(k / 10));

		if (r % k ==0)
		{
			System.out.println(r / k);
			in.close();
			return;
		}

		for (;;)
		{

			if (sum % k == 0 || (sum + r) % k == 0)
			{
				System.out.println((sum % k == 0)? sum / k: (sum + r) / k);
				break;
			}
			else
				sum += 10;
		}
		in.close();

	}

}

import java.util.Scanner;

public class JavaApplication1 {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

	int k,r;
	k=input.nextInt();  r=input.nextInt();

	if (k%10==0) System.out.println("1");
        else if (k==r) System.out.println('1');
        else if (k==1) System.out.println(r);
        else
		  for (int i=1;i<=1000;i++)
                  {
                     if(((i*10))%k==0) {System.out.println(((i*10))/k); break;}
                     else if(((i*10)+r)%k==0) {System.out.println(((i*10)+r)/k); break;}
                  }
    }

}

import java.io.*;
import java.util.*;

public class Main {

    public static void main(String [] args){
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Integer readFromFile=new Integer(1);
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskD {

        class Pair{
            int first;
            int second;
            Pair(int first, int second){
                this.first = first;
                this.second = second;
            }
            Pair(){}
        }
        class Comp implements Comparator<Integer>{
            @Override
            public int compare(Integer o1, Integer o2) {
                return (o1-o2)*-1;
            }
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int one = in.nextInt();
            int oct = n%10;
            if(oct==0 || oct%one==0){
                out.println("1");
                return;
            }
            int sum = 0;
            for(int i=1; i<=10; i++){
                if((((oct*i)%10)-one==0) || (((oct*i)%10)-one==-oct)){
                    out.println(i);
                    break;
                }
            }
        }
    }
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;
        String st1;
        File file = new File("text.txt");
        public InputReader(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
            st = null;
        }
        public InputReader(int i) {
            try {
                br  = new BufferedReader(
                        new InputStreamReader(new FileInputStream(file)));
            } catch (FileNotFoundException e1) {
                System.out.println("File is not find");
            }
            st = null;
        }
        public String next(){
            while (st==null || !st.hasMoreTokens()){
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public String nextLine(){
            try {
                st1 = new String(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return st1;
        }
        public int nextInt()  {return Integer.parseInt(next());}
        public long nextLong(){
            return Long.parseLong(next());
        }
        public Double nextDouble(){
            return Double.parseDouble(next());
        }
        public Byte nextByte() {
            return Byte.parseByte(next());
        }
        private int idx;
        public Character nextChar() {
            if(st1==null) {
                st1 = next();
                idx = 0;
            }
            if(idx!=(st1.length())-1){
                return st1.charAt(idx++);
            }else{
                char  c= st1.charAt(idx);
                st1 = null;
                return c;
            }
        }
        public void newFile() {
            try {
                FileWriter write = new FileWriter(file);
                write.write("something for cheaking");
                write.close();

            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

import java.util.Scanner;

/**
 *
 * @author aso
 */
public class Problem16 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double price = in.nextDouble();
        double price2 = price;

        int kind = in.nextInt();
        int f = 10;
        double result = 0;
        double result2 = 0;

        double n = 1;
        double n2 = 1;

        double res = 0;
        double res2 = 0;
        double fin = 0;

        while (n != res) {
            result = (n * price);
            if (result % f == 0) {
                res = n;
                break;
            }
            result = 0;
            n++;
        }
        while (n2 != res2) {
            result2 = (n2 * price2);
            if (result2 % kind == 0) {
                res2 = n2;
                break;
            }
            result2 = 0;
            n2++;
        }
        if (res2 == kind && res == f) {
            fin = 1;
        } else if (res > res2) {
            fin = res - res2;
        } else if (res == res2) {
            fin = res;
        }

        System.out.println(fin);

    }

}

import java.util.*;

public class my{

	public int solve(int q,int w ){
    int a = 0;
    int total_calc = 0;
    int sum = 0;
    int count = 0;
for(int i = 1; i<=q; i++){
total_calc = q*i;
a = total_calc % 10;
count = count + 1;
if (a == 0){
  break;
}
else{
if (a == w){
  break;
}
}
}
return  count;
	}

	public static void main(String args[]){
		my m = new my();
		Scanner sc =new Scanner(System.in);
int n = sc.nextInt();
int o =sc.nextInt();
System.out.println(m.solve(n,o));

	}
}

import java.util.*;
public class BuyShovel {

	    public static void main (String [] args){
	        Scanner sc = new Scanner(System.in);
	     int k = sc.nextInt();
	     int r = sc.nextInt();
	    for(  int num=1;num <Integer.MAX_VALUE ; ){
	    	  int price = k *num;
	         if (price%10==0 || price%10==r)
	        	 num++;
	        	 System.out.println(" the min. no. is " + num);
	        break;
	    }

	    }
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package codeforces.submissions;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 *
 * @author Joe
 */
public class CodeforcesSubmissions {

    /**
     * @param args the command line arguments
     */
    public static int getMinAmountOfShovals(int s, int n) {
        double amount = 10;
        double ans = n;
        while(((amount + n )/ s ) % 1 != 0){
            if((amount / s) % 1 == 0) {
                ans = amount /s;
                break;
            }
            amount += 10;
            ans = (amount + n)/s;
        }
        return (int)ans;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int n = sc.nextInt();

        System.out.println(getMinAmountOfShovals(s, n));
    }

}

import java.util.*;
public class shovel {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int price1=sc.nextInt();
		int price= price1;
		int amount=sc.nextInt();

		int[] prices= new int[1000];
		int[] amounts= new int[1000];

		for(int i=0;i<prices.length;i++){
			prices[i]=price;
			price+=price1;
		}

		for(int i=0;i<amounts.length;i++){
			amounts[i]= amount;
			amount+=10;
		}

		for(int i=0;i<prices.length;i++){
			for(int j=0;j<amounts.length;j++){
				if(prices[i] == amounts[j]){
					price=prices[i];
					break;
				}
			}
			if(price==prices[i]){break;}
		}

		System.out.println(price/price1);
	}
}

import java.util.*;
public class buy_a_shovel
{
    public static void main(String [] args)
    {
        Scanner sc=new Scanner(System.in);
        int k=sc.nextInt();
        int r=sc.nextInt();
        int i=k%10;;
        if(i==r||i==0)
        System.out.println("1");
        if(i!=0||i!=r)
        {
            for(int ii=2;ii<10;ii++)
            {
                int rem=(i*ii)%10;
                if(rem==0||rem==r)
                {
                System.out.println(ii);
                break;
                }
            }

        }

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;

/**
 * @author Code Forces.  Solution by: L.Azuaje.
 *

 *         Problem: 732A  Buy a Shovel.
 *

 *         Used at Codeforces: Round 377 Div-2.
 */

public class Main {

    public static int find(int price, int bankNote) {
        int solution = 0;
        int partial = 10000000;
        int i = 1;

        int priceEnd = price % 10;
        int tens = 0;

        if (priceEnd == 0) {
            solution = 1;
        } else {
            if ( 10 % priceEnd == 0 ) {
                partial = 10 / priceEnd;
            }

            if ( bankNote % priceEnd  == 0) {
                solution =  bankNote / priceEnd;
            } else {
                for (i = 1; i <= 10; i++) {
                    if ( (priceEnd + tens) % bankNote == 0 ) {
                        break;
                    } else {
                        tens += 10;
                    }
                }
                if (i == 11) {
                    solution = Math.min(10, partial);
                } else {
                    solution =  (priceEnd + tens) / bankNote;
                }
            }
        }
        return solution;
    }

    public static void main(String[] args) throws IOException {
        MyScanner scanner = new MyScanner();
        PrintStream out = System.out;

        int[] data = scanner.nextIntArray();

        out.println(find(data[0], data[1]));

        scanner.close();
        out.close();
    }

    // -----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader reader;

        public MyScanner() {
            this.reader = new BufferedReader(new InputStreamReader(System.in));
        }

        public void close() throws IOException {
            this.reader.close();
        }

        int nextInt() {
            return Integer.parseInt(this.next());
        }

        long nextLong() {
            return Long.parseLong(this.next());
        }

        double nextDouble() {
            return Double.parseDouble(this.next());
        }

        String next() {
            String str = "";
            try {
                str = this.reader.readLine().trim();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        String[] nextStringArray() {
            String[] str = null;
            try {
                str = this.reader.readLine().trim().split(" ");
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int[] nextIntArray() {
            String[] data = nextStringArray();
            int[] a = new int[data.length];

            for (int i = 0; i < a.length; i++) {
                a[i] = Integer.parseInt(data[i]);
            }

            return a;
        }

        Integer[] nextIntegerArray() {
            String[] data = nextStringArray();
            Integer[] a = new Integer[data.length];

            for (int i = 0; i < a.length; i++) {
                a[i] = Integer.parseInt(data[i]);
            }

            return a;
        }

        long[] nextLongArray() {
            String[] data = nextStringArray();
            long[] a = new long[data.length];

            for (int i = 0; i < a.length; i++) {
                a[i] = Long.parseLong(data[i]);
            }

            return a;
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class A {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String[] args) throws Exception {
        FastReader fr = new FastReader();
        int cost = fr.nextInt();
        int change = fr.nextInt();

        int rem = cost%10;
        if(rem==0){
            System.out.println(1);
        }
        else if(rem==5){
            System.out.println(2);
        }
        else{
            int ans = 1;
            while(rem!=change && rem!=0){
                ans++;
                int val = cost*ans;
                rem = val%10;
            }
            System.out.println(ans);
        }
    }
}

import java.util.Scanner;

/**
 * Created by Kamal on 26-10-2016.
 */
public class BuyAShovel
{
    private static int k;
    private static int r;

    public static int getK() {
        return k;
    }

    public static void setK(int k) {
        BuyAShovel.k = k;
    }

    public static int getR() {
        return r;
    }

    public static void setR(int r) {
        BuyAShovel.r = r;
    }

    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);

        k = scanner.nextInt();
        r = scanner.nextInt();

        System.out.println(findMinimum());
    }

    public static int getLast (int number)
    {
        return number %  10;
    }

    public static int findMinimum ()
    {
        for (int counter = 0; counter <= k; counter++)
        {
            int totalPrice = getTotalPrice(counter);

            int lastDigit = getLast(totalPrice);

            if (lastDigit == r)
                return counter;
        }

        for (int counter = 1; counter < k; counter++)
        {
            int totalPrice = getTotalPrice(counter);

            int lastDigit = getLast(totalPrice);

            if (lastDigit == 0)
                return counter;
        }

        return 0;
    }

    public static int getTotalPrice (int n)
    {
        return n * k;
    }

}

import java.util.*;

public class shovel{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);

        int cost = in.nextInt();
        int deno = in.nextInt();

        if(cost%10 == 0)
            System.out.println(1);
        else
        if(cost%5 == 0)
            System.out.println(2);
        else{
            int x = cost % 10;
            for(int i = 1 ; i < 10 ; i++){
                if((x*i)%10 == deno){
                    System.out.println(i);
                    break;
                }

            }
        }

    }
}

import java.io.*;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.Scanner;
public class shovel2
{
	public static void main(String[] args) throws IOException
	{
		int k;
		int r;
		Scanner sc=new Scanner(System.in);
		k=sc.nextInt();
		r=sc.nextInt();
		//int k=1;
		int arr[]=new int[9];
		int b[]=new int[9];
		int q=1;
		for(int i=0;i<9;i++)
		{
			arr[i]=q*k;
            b[i]=arr[i]%10;
            q++;
		}
		/*for(int i=0;i<9;i++)
		{
			System.out.print(arr[i]+" ");
		}*/
		/*System.out.println();
		for(int i=0;i<9;i++)
		{
			System.out.println(b[i]+" ");
		}*/
		if(k%10!=5 && k%10!=0)
       {
		for(int i=0;i<9;i++)
		{
			if(b[i]==r)
			{
				int j=i+1;
				System.out.println(j);
				break;
			}
       }
	     }
	if(k%10==5 && r!=5)
	{
		int u=2;
		System.out.println(u);
	}
	/*if(k%10==5 && r==5)
	{
		if(k!=5)
		{
		int z=k-5;
		int a1=z/10;
		System.out.println(a1);
	}
	else
	{
		int x=1;
		System.out.println(x);
	}*/

	 if(k%10==0)
	{
		int e=1;
		System.out.println(e);
	}
	}
}

import java.util.*;
public class sol
{
    public static void main(String[] args)
    {
        Scanner input = new Scanner(System.in);
        int b = input.nextInt();
        int k = input.nextInt();
        int i=10;
        for(i=1; i<10; i++)
        {
            if((b*i)%10==k)
                break;
        }
        System.out.print(i);
    }
}

import java.util.Scanner;

/**
 *
 * @author abosala7
 */
public class BuyShovel {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int price = sc.nextInt();
        int den = sc.nextInt();
        int sum  = 0;
        boolean add = true;
        while(add){
            sum += den;
            if (sum % price == 0 ){
                add =false;
                continue;
            }
            sum += 7;
            if (sum % price == 0 ){
                add =false;
                continue;
            }
            sum += 3;
            if (sum % price == 0 ){
                add =false;
                continue;
            }
            sum -=3;
        }
        System.out.println(sum/price);
    }
}

import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int r = sc.nextInt();
		int res = 1;
		if(k % 10 == 0 || (k-r)%10==0)
		{
		    System.out.println("1");
		    return;
		}
		if(k % 5 == 0)
		{
		    System.out.println("2");
		    return;
		}
		while(k % 10 !=0)
		{
		    k = res*k - r;
		    res++;
		}
		System.out.println(res+1);
	}
}

import java.io.*;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.Scanner;
public class shovel2
{
	public static void main(String[] args) throws IOException
	{
		int k;
		int r;
		Scanner sc=new Scanner(System.in);
		k=sc.nextInt();
		r=sc.nextInt();
		//int k=1;
		int arr[]=new int[9];
		int b[]=new int[9];
		int q=1;
		for(int i=0;i<9;i++)
		{
			arr[i]=q*k;
            b[i]=arr[i]%10;
            q++;
		}
		if(k>=r)
		{
		if(k%10!=5 && k%10!=0)
       {
		for(int i=0;i<9;i++)
		  {
			if(b[i]==r)
			{
				int j=i+1;
				System.out.println(j);
				break;
			}
          }
	  }
	if(k%10==5 && r!=5)
	{
		int u=2;
		System.out.println(u);
	}
	if(k%10==5 && r==5)
	{
	   int z=1;
	   System.out.println(z);
	}
	 if(k%10==0)
	{
		int e=1;
		System.out.println(e);
	}
}
else
{
	int g=0;
	System.out.println(g);
	}
}
}

/**
 *
 * @author Pollock
 */
import java.util.*;

public class buy_a_shovel {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        a = a % 10;
       // System.out.println("a "+a);
        int ans = 1;
        for (int i = 1; i <= 10; i++) {
            if (((a * i) % 10 == 0) || ((a * i) % 10 == b)) {
               ans++;
                break;
            }
        }
        System.out.println(ans);
    }
}

import java.util.*;

public class Solving {

private static Scanner in =new Scanner(System.in);
 public static int lower(int arr[], int n, int X) {
     if (X < arr[0])
         return 0;
     else if (X > arr[n - 1])
         return n;
     int lowerPnt = 0;
     int i = 1;
     while (i < n && arr[i] < X) {
         lowerPnt = i;
         i = i * 2;
     }
     while (lowerPnt < n && arr[lowerPnt] < X)
         lowerPnt++;

     return lowerPnt;
    }
 public static void main(String[] args){
   int n=in.nextInt();
   int tmp=n;
   int k=in.nextInt();
   int count=0;
   if(n==1)
         System.out.println(k);
   else{
       if(n%10==0||n%10==k)
       count=0;
   else{
        while(n%10!=3&&n%10!=0){
            count++;
            n+=tmp;
        }
   }
     System.out.println(count+1);
   }
 }
}

import java.util.Scanner;
public class shovel {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner cs= new Scanner(System.in);
		int k= cs.nextInt();
		int k1=k;
		int shvls=1;
		int r=cs.nextInt();
		int amount=r;

		while(k>=amount && amount-k!=0){
			if(k>amount){
				amount+=10;
			}
			if(amount>k){
				k+=k1;shvls++;amount+=10;
			}
		}
		System.out.println(shvls);

	}

}

import java.io.*;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.Scanner;
public class shovel2
{
	public static void main(String[] args) throws IOException
	{
		int k;
		int r;
		Scanner sc=new Scanner(System.in);
		k=sc.nextInt();
		r=sc.nextInt();
		//int k=1;
		int arr[]=new int[9];
		int b[]=new int[9];
		int q=1;
		for(int i=0;i<9;i++)
		{
			arr[i]=q*k;
            b[i]=arr[i]%10;
            q++;
		}
		/*for(int i=0;i<9;i++)
		{
			System.out.print(arr[i]+" ");
		}*/
		/*System.out.println();
		for(int i=0;i<9;i++)
		{
			System.out.println(b[i]+" ");
		}*/
		if(k%10!=5 && k%10!=0)
       {
		for(int i=0;i<9;i++)
		{
			if(b[i]==r)
			{
				int j=i+1;
				System.out.println(j);
				break;
			}
       }
	     }
	if(k%10==5)
	{
		int u=2;
		System.out.println(u);
	}
	/*if(k%10==5 && r==5)
	{
		if(k!=5)
		{
		int z=k-5;
		int a1=z/10;
		System.out.println(a1);
	}
	else
	{
		int x=1;
		System.out.println(x);
	}*/

	 if(k%10==0)
	{
		int e=1;
		System.out.println(e);
	}
	}
}

import java.io.*;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.Scanner;
public class shovel2
{
	public static void main(String[] args) throws IOException
	{
		int k;
		int r;
		Scanner sc=new Scanner(System.in);
		k=sc.nextInt();
		r=sc.nextInt();
		//int k=1;
		int arr[]=new int[9];
		int b[]=new int[9];
		int q=1;
		for(int i=0;i<9;i++)
		{
			arr[i]=q*k;
            b[i]=arr[i]%10;
            q++;
		}

		int o=0;
		if(k%10!=5 && k%10!=0)
       {
		for(int i=0;i<9;i++)
		  {
			if(b[i]==r)
			{
				int j=i+1;
				o++;
				System.out.println(j);
				break;
			}
          }
           if(o==0)
           {
           	int e=10;
           	System.out.println(e);
           }
	  }
	if(k%10==5 && r!=5)
	{
		int u=2;
		System.out.println(u);
	}
	if(k%10==5 && r==5)
	{
	   int z=1;
	   System.out.println(z);
	}
	 if(k%10==0)
	{
		int e=10;
		System.out.println(10);
	}
  }

}

import java.util.Scanner;

public class BuyShowel {
public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
        int k=sc.nextInt();
        int r=sc.nextInt();
        if(k%10==0)
        {
            System.out.println("1");
        }
        else if((k)%10==5)
        {
            System.out.println("2");
        }else {
        for(int i=1;i<=10;i++)
        {

        if((k*i)%10==r)
        {
            System.out.println(i);
            break;
        }
        }
}}

}

import java.util.*;
public class Main{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int c=0;
        for(int i=0;i<=100;i++)
        {
            if(((n*i)%10)==k)
            {
            c=i;
            break;
            }
        }
        System.out.println(c);
    }
}

import java.io.*;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.Scanner;
public class shovel2
{
	public static void main(String[] args) throws IOException
	{
		int k;
		int r;
		Scanner sc=new Scanner(System.in);
		k=sc.nextInt();
		r=sc.nextInt();
		//int k=1;
		int arr[]=new int[9];
		int b[]=new int[9];
		int q=1;
		for(int i=0;i<9;i++)
		{
			arr[i]=q*k;
            b[i]=arr[i]%10;
            q++;
		}
		/*for(int i=0;i<9;i++)
		{
			System.out.print(arr[i]+" ");
		}*/
		/*System.out.println();
		for(int i=0;i<9;i++)
		{
			System.out.println(b[i]+" ");
		}*/
		if(k%10!=5 && k%10!=0)
       {
		for(int i=0;i<9;i++)
		{
			if(b[i]==r)
			{
				int j=i+1;
				System.out.println(j);
				break;
			}
       }
	     }
	if(k%10==5)
	{
		int u=2;
		System.out.println(u);
	}
	if(k%10==5 && r==5)
	{
	   int z=1;
	   System.out.println(z);
	}
	/*/else
	{
		int x=1;
		System.out.println(x);
	}*/

	 if(k%10==0)
	{
		int e=1;
		System.out.println(e);
	}
	}
}

import java.util.*;

public class Learning {
 public static void main(String[] args) {
	Scanner input = new Scanner(System.in);
	int shovelPrice = input.nextInt();
	int changeCoin = input.nextInt();
	int requiredNumber = 0;
	for(int i = 0 ; i < 10 ;i++) {
	    	if(shovelPrice % 10 == 0) {
			requiredNumber = 1 ;
			break;
		}
		if(shovelPrice % 5 == 0) {
			requiredNumber = 2 ;
			break;
		}
		if(((shovelPrice*i)) % 10 == 0) {
			requiredNumber = requiredNumber + i;
			break;
		}
		if(((shovelPrice*i) - changeCoin) % 10 == 0) {
			requiredNumber = requiredNumber + i;
			break;
		}
	}
	System.out.println(requiredNumber);
 }
}

import java.util.*;
public class Shovel
{
    public static void main(String[] args)
    {
        int k, r, x=0;
        Scanner sc = new Scanner(System.in);
        k = sc.nextInt();
        r = sc.nextInt();
        if(k%10==5)
            x = 2;
        else if(k%10==0)
            x = 1;
        else if(k%2==0)
        {
            if(r%2==1)
                x = 5;
            else
            {
                for(int i=1;i<5;i++)
                {
                    if(((k*i)-r)%10 ==0)
                        x = i;
                }
            }
        }
        else
        {
            for(int i=1;i<10;i++)
            {
                if(((k*i)-r )%10 == 0)
                    x = i;
            }
        }
        System.out.print(x);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class BuyAShovel {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] temp = in.readLine().split(" ");
		int n = Integer.parseInt(temp[0]);
		int k = Integer.parseInt(temp[1]);
		int u = n % 10;
		if(u == 0 || u == k) {
			System.out.println(1);
		} else {
			if(u%2 == 0){
				System.out.println(5);
			} else {
				int i = 1;
				while(i<10 && (k*i)%u != 0) {
					i++;
				}
				if(i<10) {
					System.out.println(i);
				} else {
					System.out.println(10);
				}
			}
		}
	}
}

import java.util.*;
import java.lang.*;
 public class shovel{
 public static void main(String args[]){
 Scanner sc= new Scanner(System.in);
   int price=sc.nextInt();
   int change=sc.nextInt();
   int i=1;
   while(price*i%10!=0||(price+change)*i%10!=0||(price-change)*i%10!=0){
      i++;
   }
   System.out.print(i);
 }
 }

import java.util.*;

public class Main{

     public static void main(String []args){
        System.out.println("Hello World");

        Scanner scc =new Scanner(System.in);
        int n=scc.nextInt();
        int k=scc.nextInt();

        int d=n%10;
        int i=1;
        while(true){
            if((d*i)%10==k||(d*i)%10==0)
            break;
            i++;
        }

        System.out.println(i);

     }
}

import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int c = 1;
	    int k = sc.nextInt();
	    int a = k;
	    int r = sc.nextInt();
	    if(k%10 == 0){
	       System.out.println(1);
	    }
	    else if(k%5 == 0){
	        System.out.println(k/10+1);

	    }
        else{
        while(k%10!=r){
            k+=a;
            c++;
        }
        System.out.println(c);
        }
	}
}

import java.util.Scanner;
public class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        int cost=scan.nextInt();
        int singlew=scan.nextInt();

        int no=0;

        if(cost%10==0){
            System.out.println("1");
        }
        else if(cost==1){
            if(cost<=singlew){
                no=singlew;
                System.out.println(no);
            }
            else{
                System.out.println("10");
            }
        }

        else{
            if((cost%10)%singlew==0){
                System.out.println("1");
            }
            else if(cost%5==0){
                System.out.println("2");
            }
            else {
                while(((7*no)%10)-singlew==0){
                    no++;
                }
                System.out.println(no);
            }
        }
    }
}

import java.util.Scanner;
public class buy_shovel {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int k=in.nextInt();
		int r=in.nextInt();
		int min=0;
		int check=k;
		while (check%10!=0) {
			if (check%10==r||check%10==0) {
				break;
				}
			min++;
			check=k*min;

		}
		System.out.println(min);
		System.out.println(k);

		in.close();
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class BuyAShovel {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] temp = in.readLine().split(" ");
		int n = Integer.parseInt(temp[0]);
		int k = Integer.parseInt(temp[1]);
		int u = n % 10;
		if(u == 0 || u == k) {
			System.out.println(1);
		} else {
			if(u%2 == 0){
				System.out.println(5);
			} else if(u == 5) {
				System.out.println(2);
			} else if(u < k) {
				System.out.println(k/u);
			} else {
				int i = 1;
				while(i<10 && (k*i)%10 != u) {
					i++;
				}
				if(i<10) {
					System.out.println(i);
				} else {
					System.out.println(10);
				}
			}
		}
	}
}

import java.util.Scanner;

/**
 * Created by Kamal on 26-10-2016.
 */
public class BuyAShovel
{
    private static int k;
    private static int r;

    public static int getK() {
        return k;
    }

    public static void setK(int k) {
        BuyAShovel.k = k;
    }

    public static int getR() {
        return r;
    }

    public static void setR(int r) {
        BuyAShovel.r = r;
    }

    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);

        k = scanner.nextInt();
        r = scanner.nextInt();

        System.out.println(findMinimum());
    }

    public static int getLast (int number)
    {
        return number %  10;
    }

    public static int findMinimum ()
    {
        for (int counter = 10; counter >= 0; counter--)
        {
            int totalPrice = getTotalPrice(counter);

            int lastDigit = getLast(totalPrice);

            if (lastDigit == r)
                return counter;
        }

        for (int counter = 1; counter <= 10; counter++)
        {
            int totalPrice = getTotalPrice(counter);

            int lastDigit = getLast(totalPrice);

            if (lastDigit == 0)
                return counter;
        }

        return 0;
    }

    public static int getTotalPrice (int n)
    {
        return n * k;
    }

}

import java.util.Scanner;

public class BuyShowel {
public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
        int k=sc.nextInt();
        int r=sc.nextInt();
        if(k%10==0)
        {
            System.out.println("1");
        }
        else if((k)%10==5)
        {
            System.out.println("2");
        }else {
        for(int i=1;i<=10;i++)
        {

        if((k*i)%10==r)
        {
            System.out.println(i);
            break;
        }
        else if((k*i)%10==0)
        {
            System.out.println(i);
            break;
        }
        }
}

}

}

import java.util.*;

public class Learning {
 public static void main(String[] args) {
	Scanner input = new Scanner(System.in);
	int shovelPrice = input.nextInt();
	int changeCoin = input.nextInt();
	int requiredNumber = 0;
	for(int i = 1 ; i < 10 ;i++) {
	    	if(shovelPrice % 10 == 0) {
			requiredNumber = 1 ;
			break;
		}
		if(shovelPrice % 5 == 0) {
			requiredNumber = 2 ;
			break;
		}
		if(((shovelPrice*i)) % 10 == 0) {
			requiredNumber = requiredNumber + i;
			break;
		}
		if(((shovelPrice*i) - changeCoin) % 10 == 0) {
			requiredNumber = requiredNumber + i;
			break;
		}
	}
	System.out.println(requiredNumber);
 }
}

import java.util.*;
import java.lang.*;
 public class shovel{
 public static void main(String args[]){
 Scanner sc= new Scanner(System.in);
   int price=sc.nextInt();
   int change=sc.nextInt();
   int i=1;
   while(price*i%10!=0&&(price*i+change)%10!=0&&(price*i-change)%10!=0){
      i++;
   }
   System.out.print(i);
 }
 }

import java.util.*;
public class asd
{
         public static void main(String args[])throws Exception
         {
                  Scanner s=new Scanner(System.in);
                  int a=s.nextInt();
                  int b=s.nextInt();int i=1;int sum=0;int c=0;
                  while(true)
                  {
                      sum=sum+a;
                     // if(i<=10)
                      if(i<=10&&sum%10==b)
                      {
                               System.out.println(i);
                               break;
                      }
                      if(i>10)
                      {
                      System.out.println("1");break;
                      }
                      i++;
                  }
         }
}

import java.util.*;
import java.lang.*;

public class Solution{
    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        int cost = scan.nextInt();
        int r = scan.nextInt();
        int ans = 10;
        for(int i=1;i<10;i++){
            int test = (cost*i)-r;
            int c = cost*i;
            if(test%10==0 || c%i==0){
                ans=i;
                break;
            }
        }
        System.out.println(ans);
    }
}

import java.util.Scanner;

public class BuyShowel {
public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
        int k=sc.nextInt();
        int r=sc.nextInt();
        if(k==r)
        {
            System.out.println("1");
        }
        else if(k%10==0)
        {
            System.out.println("1");
        }
        else if((k)%10==5)
        {
            System.out.println("2");
        }else {
        for(int i=1;i<=10;i++)
        {

        if((k*i)%10==r)
        {
            System.out.println(i);
            break;
        }
        else if((k*i)%10==0)
        {
            System.out.println(i);
            break;
        }
        }
}

}

}

import java.io.*;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.Scanner;
public class shovel2
{
	public static void main(String[] args) throws IOException
	{
		int k;
		int r;
		Scanner sc=new Scanner(System.in);
		k=sc.nextInt();
		r=sc.nextInt();
		//int k=1;
		int arr[]=new int[9];
		int b[]=new int[9];
		int q=1;
		for(int i=0;i<9;i++)
		{
			arr[i]=q*k;
            b[i]=arr[i]%10;
            q++;
		}
		/*for(int i=0;i<9;i++)
		{
			System.out.print(arr[i]+" ");
		}*/
		/*System.out.println();
		for(int i=0;i<9;i++)
		{
			System.out.println(b[i]+" ");
		}*/
		if(k%10!=5 && k%10!=0)
		{
		for(int i=0;i<9;i++)
		{
			if(b[i]==r)
			{
				int j=i+1;
				System.out.println(j);
				break;
			}
		}
	}
	else if(k%10==5)
	{
		int u=2;
		System.out.println(u);
	}
	else if(k%10==0)
	{
		int e=0;
		System.out.println(e);
	}
	}
}

import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class BuyAShovel {

    public static void main(String[] args) {
        InputReader ir = new InputReader(System.in);

        int k = ir.nextInt();
        int r = ir.nextInt();
        int d = 1;
        int num;

        if(k % r == 0) {
            System.out.println(1);
            return;
        }

        do {
            num = 10 * d;

            if(num % k == 0) {
                break;
            }

            num += r;
            d++;

        } while (num % k != 0);

        System.out.println(num / k);
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int snext() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public String readString() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = snext();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
}

import java.util.Scanner;

/**
 *
 * @author aso
 */
public class Problem16 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double price = in.nextDouble();
        double price2 = price;

        int kind = in.nextInt();
        int f = 10;
        double result = 0;
        double result2 = 0;

        int n = 1;
        int n2 = 1;

        int res = 0;
        int res2 = 0;
        int fin = 0;

        while (n != res) {
            result = (n * price);
            if (result % f == 0) {
                res = n;
                break;
            }
            result = 0;
            n++;
        }
        while (n2 != res2) {
            result2 = (n2 * price2);
            if (result2 % kind == 0) {
                res2 = n2;
                break;
            }
            result2 = 0;
            n2++;
        }
        if (res2 == kind && res == f && res - res2 != 1) {
            fin = 1;
        } else if (res2 == kind && res == f && res - res2 == 1) {
            fin = res2;

        } else if (res > res2) {
            fin = res - res2;
        } else if (res == res2) {
            fin = res;
        }

        System.out.println(fin);

    }

}

import java.util.*;
public class BuyShovel {

       public static void main (String [] args){
           Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int r = sc.nextInt();
        int num=0;
        int total = k *num;
        while(num <9){
            if (total%10==0 || total%r==0){
            	 num++;

            }
        }
       System.out.println(num);
        }
        }

import java.util.*;

public class shovel{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);

        int cost = in.nextInt();
        int deno = in.nextInt();

        if(cost%10 == 0)
            System.out.println(1);
        else
        if(cost%5 == 0)
            System.out.println(2);
        else{
            int x = cost % 10;
            for(int i = 1 ; i < 10 ; i++){
                if((x*i)%10 == deno)
                    System.out.println(i);
            }
        }

    }
}

import java.io.*;
import java.util.StringTokenizer;
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tk=new StringTokenizer(bf.readLine());
        int a=Integer.parseInt(tk.nextToken());
        int b=Integer.parseInt(tk.nextToken());
        int i=1;
        int temp=-2;
        while(temp%10!=0 && (temp-b)%10!=0){
        temp=i*a;
        i++;
        }
        int res=i-1;
        PrintWriter pw=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        pw.write(((res==0)?1:res)+"\n");
        pw.flush();
    }}