namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            long l;
            long r;
            string readStr = Console.ReadLine();
            string[] arg = readStr.Split(' ');
            l = int.Parse(arg[0]);
            r = int.Parse(arg[1]);

            Console.Write("{0}", palindrom(r) - palindrom(l-1));
        }

        public static long palindrom(long arg)
        {
            string str = arg.ToString();

            if (str.Length == 1)
                return long.Parse(str[0].ToString());
            else
            {
                long res = 0;
                for (int i = 2; i <= str.Length-1; i++)
                {
                        res += (long)Math.Pow(10, i-2) * 9;
                }

                int firstDigit = int.Parse(str[0].ToString());
                int lastDigit = int.Parse(str[str.Length - 1].ToString());
                int min = Math.Min(firstDigit, lastDigit);

                res += (long)Math.Pow(10, str.Length - 2) * (min-1);
                res += 9;

                long buf = 1;
                for (int i = str.Length-2; i >= 1 ; i--)
                    buf *= (long.Parse(str[i].ToString()) + 1);

                res += buf;
                return res;
            }
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            long l;
            long r;
            string readStr = System.Console.ReadLine();
            string[] arg = readStr.Split(' ');
            l = long.Parse(arg[0]);
            r = long.Parse(arg[1]);

            System.Console.Write("{0}", palindrom(r) - palindrom(l-1));
        }

        public static long palindrom(long arg)
        {
            string str = arg.ToString();

            if (str.Length == 1)
                return long.Parse(str[0].ToString());
            else
            {
                long res = 0;
                for (int i = 2; i <= str.Length-1; i++)
                {
                    res += (long)System.Math.Pow(10, i - 2) * 9;
                }

                int firstDigit = int.Parse(str[0].ToString());
                int lastDigit = int.Parse(str[str.Length - 1].ToString());
                int min = System.Math.Min(firstDigit, lastDigit);
                int max = System.Math.Max(firstDigit, lastDigit);

                res += (long)System.Math.Pow(10, str.Length - 2) * (firstDigit-1);
                res += 9;

                string s = str.Remove(0, 1);
                s = s.Remove(s.Length - 1, 1);
                if (s == "")
                    res++;
                else res += long.Parse(s) + 1;

                if (firstDigit > lastDigit)
                    res--;

                return res;
            }
        }
    }
}


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

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

        private static void Main(string[] args)
        {
            string[] ss = reader.ReadLine().Split(' ');

            string sl = ss[0];
            string sr = ss[1];

            long count = 0;
            long d = 1;
            for (int i = 0; i < sl.Length - 1; i++)
            {
                d *= 10;
            }
            for (int i = sl.Length + 1; i < sr.Length; i++)
            {
                count += 9*d;
                d *= 10;
            }

            if (sl.Length == sr.Length)
            {
                count += Bigger(sl, true) - Bigger(sr, false);
            }
            else
            {
                count += Bigger(sl, true);
                count += 9*d - Bigger(sr, false);
            }

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

        private static long Bigger(string sl, bool border)
        {
            long l = long.Parse(sl);
            if (sl.Length == 1)
            {
                return 10 - l - (border ? 0 : 1);
            }

            long d = 1;
            for (int i = 0; i < sl.Length - 2; i++)
            {
                d *= 10;
            }
            long count = d*(10 - (sl[0] - '0') - 1);

            char[] cl = sl.ToCharArray();
            cl[cl.Length - 1] = cl[0];

            var sd = new string(cl, 1, cl.Length - 2);
            if (sd.Length == 0)
                sd = "0";
            long dd = long.Parse(sd);
            long ll = long.Parse(new string(cl));

            if (ll < l || (ll == l && !border))
                dd++;

            count += d - dd;

            return count;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Collections;
using System.Text.RegularExpressions;

namespace Task
{

    #region MyIo

    internal class MyIo : IDisposable
    {
        private readonly TextReader inputStream;
        private readonly TextWriter outputStream = Console.Out;

        private string[] tokens;
        private int pointer;

        public MyIo()
#if  LOCAL_TEST
            : this(new StreamReader("input.txt"))
#else
            : this(System.Console.In)
#endif
        {

        }

        public MyIo(TextReader inputStream)
        {
            this.inputStream = inputStream;
        }

        public char NextChar()
        {
            try
            {
                return (char)inputStream.Read();
            }
            catch (IOException)
            {
                return '\0';
            }
        }

        public string NextLine()
        {
            try
            {
                return inputStream.ReadLine();
            }
            catch (IOException)
            {
                return null;
            }
        }

        public string NextString()
        {
            try
            {
                while (tokens == null || pointer >= tokens.Length)
                {
                    tokens = (NextLine() + string.Empty).Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    pointer = 0;
                }
                return tokens[pointer++];
            }
            catch (IOException)
            {
                return null;
            }
        }

        public int NextInt()
        {
            return Next<int>();
        }

        public long NextLong()
        {
            return Next<long>();
        }

        public T Next<T>()
        {
            var t = typeof(T);

            if (t == typeof(char))
                return (T)(object)NextChar();

            object s = NextString();

            if (t == typeof(string))
                return (T)s;

            return (T)Convert.ChangeType(s, typeof(T));
        }

        public IEnumerable<T> NextWhile<T>(Predicate<T> pred)
        {
            if (pred == null)
                yield break;

            T res = Next<T>();

            while (pred(res))
            {
                yield return res;

                res = Next<T>();
            }
        }

        public IEnumerable<T> NextSeq<T>(long n)
        {
            for (var i = 0; i < n; i++)
                yield return Next<T>();
        }

        public void Print(string format, params object[] args)
        {
            outputStream.Write(string.Format(CultureInfo.InvariantCulture, format, args));
        }

        public void PrintLine(string format, params object[] args)
        {
            Print(format, args);

            outputStream.WriteLine();
        }

        public void Print(bool o)
        {
            Print(o ? "yes" : "no");
        }

        public void PrintLine(bool o)
        {
            Print(o);

            outputStream.WriteLine();
        }

        public void Print<T>(T o)
        {
            outputStream.Write(Convert.ToString(o, CultureInfo.InvariantCulture));
        }

        public void PrintLine<T>(T o)
        {
            Print(o);

            outputStream.WriteLine();
        }

        public void Close()
        {
            inputStream.Close();
            outputStream.Close();
        }

        void IDisposable.Dispose()
        {
            Close();

#if  LOCAL_TEST
            Console.ReadLine();
#endif
        }
    }

    public static class ListExtensions
    {
        public static void Each<T>(this IEnumerable<T> self, Action<T> action)
        {
            foreach (var v in self)
                action(v);
        }

        public static IEnumerable<T> ToCycleEnumerable<T>(this IEnumerable<T> self)
        {
            if (self != null)
            {
                for (; ; )
                {
                    foreach (var x in self)
                        yield return x;
                }
            }
        }

        public static T CycleGet<T>(this IList<T> self, int index)
        {
            var c = self.Count;
            return self[(index % c + c) % c];
        }

        public static IList<T> Shuffle<T>(this IList<T> self)
        {
            var rnd = new Random(DateTime.Now.Millisecond);

            var n = self.Count;

            while (n > 1)
            {
                n--;
                var k = rnd.Next(n + 1);
                var value = self[k];
                self[k] = self[n];
                self[n] = value;
            }

            return self;
        }

        public static IList<IList<T>> UseForNew2D<T>(this T def, int fd, int sd)
        {
            var fdim = new T[fd][];

            for (int i = 0; i < fd; i++)
            {
                fdim[i] = new T[sd];
                Fill(fdim[i], def);
            }

            return fdim;
        }

        public static IList<T> Fill<T>(this IList<T> self, Func<T> fval)
        {
            for (var i = 0; i < self.Count; i++)
                self[i] = fval();

            return self;
        }

        public static IList<T> Fill<T>(this IList<T> self, T val)
        {
            return self.Fill(() => val);
        }

        public static long Hash<T>(this IList<T> self, Func<T, long> val = null)
        {
            return val != null ? self.Hash((t, current) => unchecked(current * 19L + val(t))) : self.Hash(HashOne);
        }

        public static long Hash<T>(this IList<T> self, Func<T, long, long> val)
        {
            return self.Aggregate(0L, (current, t) => unchecked(val(t, current)));
        }

        public static long HashOne<T>(this T self, long current)
        {
            return unchecked(current * 19L + (Equals(self, default(T)) ? 0 : self.GetHashCode()));
        }

        public static IList<T1> BuildSegTree<T1, T2>(this IList<T2> a, Func<T1, T1, T1> combine, Func<T2, T1> convert)
        {
            var t = new T1[a.Count << 2];

            a.BuildSegTree(t, 1, 0, a.Count - 1, combine, convert);

            return t;
        }

        private static void BuildSegTree<T1, T2>(this IList<T2> a, IList<T1> t, int v, int tl, int tr, Func<T1, T1, T1> combine, Func<T2, T1> convert)
        {
            if (tl == tr)
            {
                t[v] = convert(a[tl]);
            }
            else
            {
                int tm = (tl + tr) >> 1;

                BuildSegTree(a, t, v << 1, tl, tm, combine, convert);
                BuildSegTree(a, t, (v << 1) + 1, tm + 1, tr, combine, convert);

                t[v] = combine(t[v << 1], t[(v << 1) + 1]);
            }
        }
    }

    public static class P
    {
        public static P<T1, T2> Create<T1, T2>(T1 key, T2 val)
        {
            return new P<T1, T2>(key, val);
        }
    }

    public class P<T1, T2>
    {
        private class PComparer : IComparer<P<T1, T2>>
        {
            private readonly bool? byKey;

            public PComparer(bool? byKey)
            {
                this.byKey = byKey;
            }

            public int Compare(P<T1, T2> x, P<T1, T2> y)
            {
                x = x ?? new P<T1, T2>();
                y = y ?? new P<T1, T2>();

                if (byKey == true)
                    return Comparer<T1>.Default.Compare(x.Key, y.Key);
                else if (byKey == false)
                    return Comparer<T2>.Default.Compare(x.Value, y.Value);
                else
                {
                    var tr = Comparer<T1>.Default.Compare(x.Key, y.Key);

                    if (tr != 0)
                        tr = Comparer<T2>.Default.Compare(x.Value, y.Value);

                    return tr;
                }
            }
        }

        public P()
        {
        }

        public P(T1 key, T2 val)
        {
            this.Key = key;
            this.Value = val;
        }

        public T1 Key
        {
            get;
            set;
        }

        public T2 Value
        {
            get;
            set;
        }

        public P<T1, T2> Clone()
        {
            return new P<T1, T2>(Key, Value);
        }

        public static IComparer<P<T1, T2>> KeyComparer
        {
            get { return new PComparer(true); }
        }

        public static IComparer<P<T1, T2>> ValueComparer
        {
            get { return new PComparer(false); }
        }

        public static implicit operator T1(P<T1, T2> obj)
        {
            return obj.Key;
        }

        public static implicit operator T2(P<T1, T2> obj)
        {
            return obj.Value;
        }

        public P<T1, T2> SetKey(T1 key)
        {
            Key = key;
            return this;
        }

        public P<T1, T2> SetValue(T2 value)
        {
            Value = value;
            return this;
        }

        public override string ToString()
        {
            return string.Format("Key: {0}, Value: {1}", Key, Value);
        }

        public override bool Equals(object obj)
        {
            var co = obj as P<T1, T2>;

            return co != null && co.GetHashCode() == GetHashCode();
        }

        public override int GetHashCode()
        {
            int hash = 17;
            hash = hash * 31 + ((Equals(Key, default(T1))) ? 0 : Key.GetHashCode());
            hash = hash * 31 + ((Equals(Value, default(T1))) ? 0 : Value.GetHashCode());
            return hash;

        }
    }

    #endregion

    internal class Program
    {
        #region Program

        private readonly MyIo io;

        public Program(MyIo io)
        {
            this.io = io;
        }

        public static void Main(string[] args)
        {
            using (MyIo io = new MyIo())
            {
                new Program(io)
                    .Solve();
            }
        }

        #endregion
        public const long MOD = 1000000007;
        public const double EPS = 1e-14;

        private void Solve()
        {
            var a = io.NextLong();
            var b = io.NextLong();

            io.Print(Calc(b) - Calc(a-1));
        }

        private long Calc(long a)
        {
            var al = a.ToString().Length;

            if (al == 1)
                return a;
            else
            {
                var dgts = new long[al];

                var xa = a;

                for (int i = 0; i < al; i++)
                {
                    dgts[al- i -1] = xa % 10;
                    xa = xa / 10;
                }

                long res = (long)Math.Pow(10, al - 2) * (dgts[0] - 1) + 9;

                for (int i = 2; i < al ; i++)
                    res += (long)Math.Pow(10, i - 2) * 9;

                if (al < 2)
                    res++;
                else
                    res += (a % (long)Math.Pow(10, al - 1))/10 + 1;

                if (dgts[0] > dgts[al - 1])
                    res--;

                return res;
            }
        }
    }

}


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

class Program
{
    static TextReader reader;
    static TextWriter writer;
    const double EPS = 1e-7;
    static Program()
    {
#if ONLINE_JUDGE
                reader = Console.In;
                writer = Console.Out;
#else
        reader = new StreamReader("input.txt");
        writer = new StreamWriter("output.txt");
#endif
    }
    static long gcd(long a, long b)
    {
        return (b != 0) ? gcd(b, a % b) : a;
    }
    static void swap(ref int a, ref int b)
    {
        int t = a;
        a = b;
        b = t;
    }
    static long pow(long a, long x, long mod = long.MaxValue)
    {
        long res = 1;
        while (x > 0)
        {
            if ((x & 1) == 1)
            {
                res = (res * a) % mod;
                --x;
            }
            else
            {
                a = (a * a) % mod;
                x >>= 1;
            }
        }
        return res;
    }
    struct C
    {
        public long x, y;
        public C(long c, long d)
        {
            x = c;
            y = d;
        }
    }
    struct Pair<T>
    {
        public T first, second;
        public Pair(T f, T s)
        {
            first = f;
            second = s;
        }
    }
    static void _a()
    {

    }
    static void _b()
    {

    }
    static long log10(long x)
    {
        long l = 0;
        while (x > 9)
        {
            ++l;
            x /= 10;
        }
        return l;
    }
    static long f(long x)
    {
        long ans = Math.Min(x, 9), len = log10(x) + 1, p = pow(10, len - 1), xf = x / p, xl = x % 10;
        for (int l = 0; l <= len - 2; ++l)
        {
            for (int i = 1; i <= 9; ++i)
            {
                if (l < len - 2 || i < xf)
                    ans += pow(10, l);
                else
                {
                    ans += (x - x / p * p) / 10;
                    if (i <= xl)
                        ++ans;
                    break;
                }
            }
        }
        return ans;
    }
    static void _c()
    {
        string[] lr = reader.ReadLine().Split();
        long l = long.Parse(lr[0]), r = long.Parse(lr[1]), ans = f(r);
        ans -= (l == 1) ? 0 : f(l-1);
        writer.Write(ans);
    }
    static void _d()
    {

    }
    static void Main(string[] args)
    {
        _c();
        reader.Close();
        writer.Close();
    }
}


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

namespace CodeforcesSolution
{
    class ProgramCF
    {
        static ConsoleInput inp;
        static void Main ( string[] args )
        {
            try
            {
                if ( File.Exists ( @"d:\zin.txt" ) )
                    Console.SetIn ( new StreamReader ( @"d:\zin.txt" ) );
            }
            catch
            {
            }
            inp = new ConsoleInput ( );
            inp.ReadAll ( );
            long L = inp.NextLong ( );
            long R = inp.NextLong ( );
            long[] cntNumDigit = new long[20];
            cntNumDigit[1] = 10; //0~9
            cntNumDigit[2] = cntNumDigit[1] + 9; //0~99
            cntNumDigit[3] = cntNumDigit[2] + 10 * 9;
            long k=10;
            for ( int i = 4; i < 20; i++ )
            {
                k *= 10;
                cntNumDigit[i] = cntNumDigit[i - 1] + ( k * 9 );
            }
            long fr = F ( R, cntNumDigit );
            long fl = F ( L - 1, cntNumDigit );
            long ans = fr - fl;

            // start here
            // ====
            WriteLine ( ans );

        }

        private static long F ( long n, long[] cntNumDigit )
        {
            if ( n < 100 )
            {
                int cnt=0;
                for ( int i = 0; i <= n; i++ )
                {
                    string s = i.ToString ( );
                    if ( s[0] == s[s.Length - 1] )
                        cnt++;
                }
                return cnt;
            }
            else
            {
                int len = n.ToString().Length;
                long res=cntNumDigit[len - 1];
                long left = n.ToString ( )[0] - '0';
                long right = n % 10;
                long mid = long.Parse ( n.ToString ( ).Substring ( 1, len - 2 ) );
                for ( int i = 1; i <= 9; i++ )
                {
                    if ( i < left )
                    {
                        long add = long.Parse ( "1" + new string ( '0', len - 2 ) );
                        res += add;
                    }
                    else if ( i == left )
                    {
                        res += mid + 1;
                        if ( right < left )
                            res -= 1;
                    }
                }
                return res;
            }
        }

        private static void WriteLine ( object value )
        {
            Console.WriteLine ( string.Format ( CultureInfo.InvariantCulture, "{0}", value ) );
        }

        class ConsoleInput
        {
            List<string> lines = new List<string> ( );
            int idx=0;

            public void ReadAll ( )
            {
                while ( true )
                {
                    string line = Console.ReadLine ( );
                    if ( line == null )
                        break;
                    lines.AddRange ( line.Split ( ' ' ) );
                }
            }

            public string NextString ( )
            {
                return lines[idx++];
            }

            public int NextInt ( )
            {
                return int.Parse ( lines[idx++] );
            }

            public long NextLong ( )
            {
                return long.Parse ( lines[idx++] );
            }

            public double NextDouble ( )
            {
                return double.Parse ( lines[idx++] );
            }

        }

    }
}


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

namespace CodeForce97
{
	class ClassC
	{
		static long Pow10(int p)
		{
			long ans = 1;
			for (int i = 0; i < p; i++)
				ans *= 10;
			return ans;
		}
		static long a(string s)
		{
			long ans = 0;
			if (s.Length == 1)
				return int.Parse(s);

			int d1 = int.Parse(s[0].ToString());
			int l = s.Length;

			ans = 9;
			for (int i = 1; i<l-1; i++)
			{
				ans += 9*Pow10(i-1);
			}

			ans += (d1 - 1) * Pow10(l - 2);

			if (l == 2)
			{
				if (s[0] <= s[s.Length - 1])
					ans++;
			}
			else
			{
				ans += long.Parse(s.Substring(1, l - 2))+1;
				if (s[0] > s[s.Length - 1])
					ans--;
			}
			return ans;
		}

		static void Main(string[] args)
		{
			string[] ss = Console.ReadLine().Split(' ');
			string sl = ss[0];
			string sr = ss[1];

			long ll = a(sl);
			long lr = a(sr);
			long ans = lr - ll;
			if (sl[0] == sl[sl.Length - 1])
				ans++;

			Console.WriteLine(ans);

//			Console.ReadKey();
		}
	}

}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;

class Test
{

    static int mod = (int)1000000007;
    static long[] fact = new long[500001];
    static long[] factinv = new long[500001];
    static Dictionary<string, int> memo = new Dictionary<string, int>();
    // Driver code
    public static void Main()
    {

        // var input = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        //var t = input[0];
        //while (t > 0)
        {
            // t--;
            var input1 = Console.ReadLine().Split(' ').Select(xx => int.Parse(xx)).ToArray();
            var l = input1[0];
            var r = input1[1];
            //var arr = Console.ReadLine().Split(' ').Select(xx => int.Parse(xx)).ToArray();
            long ans = 0;

            long ten = 1;
            for (int i = 1; i <= 18; i++)
            {
                for (int d = 1; d <= 9; d++)
                {
                    long low = d * ten, high = (d + 1) * ten - 1;
                    low = Math.Max(low, l);
                    high = Math.Min(high, r);
                    while (low % 10 != d) low++;
                    while ((high % 10 + 10) % 10 != d) high--;
                    if (low <= high)
                        ans += (high - low) / 10 + 1;
                }
                ten *= 10;
            }
            Console.WriteLine(ans);
        }

    }

    public static void Run()
    {
        fact[0] = 1;
        factinv[0] = fast_pow(fact[0], mod - 2);
        for (int i = 1; i <= 500000; ++i)
        {
            fact[i] = fact[i - 1] * i % mod;
            factinv[i] = fast_pow(fact[i], mod - 2);
        }
    }
    public static long GetCom(int n, int r)
    {
        return fact[n] * factinv[r] % mod * factinv[n - r] % mod;
    }
    public static long fast_pow(long a, long b)
    {
        if (b == 0)
            return 1;
        long val = fast_pow(a, b / 2);
        if (b % 2 == 0)
            return val * val % mod;
        else
            return val * val % mod * a % mod;
    }

}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            long l;
            long r;
            string readStr = System.Console.ReadLine();
            string[] arg = readStr.Split(' ');
            l = int.Parse(arg[0]);
            r = int.Parse(arg[1]);

            System.Console.Write("{0}", palindrom(r) - palindrom(l-1));
        }

        public static long palindrom(long arg)
        {
            string str = arg.ToString();

            if (str.Length == 1)
                return long.Parse(str[0].ToString());
            else
            {
                long res = 0;
                for (int i = 2; i <= str.Length-1; i++)
                {
                    res += (long)System.Math.Pow(10, i - 2) * 9;
                }

                int firstDigit = int.Parse(str[0].ToString());
                int lastDigit = int.Parse(str[str.Length - 1].ToString());
                int min = System.Math.Min(firstDigit, lastDigit);
                int max = System.Math.Max(firstDigit, lastDigit);

                res += (long)System.Math.Pow(10, str.Length - 2) * (firstDigit-1);
                res += 9;

               // if (min != 0)
                {
                    string s = str.Remove(0, 1);
                    s = s.Remove(s.Length - 1, 1);
                    if (s == "")
                        res++;
                    else res += long.Parse(s) + 1;

                    if (firstDigit > lastDigit)
                        res--;
                }

                return res;
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Collections;
using System.Text.RegularExpressions;

namespace Task
{

    #region MyIo

    internal class MyIo : IDisposable
    {
        private readonly TextReader inputStream;
        private readonly TextWriter outputStream = Console.Out;

        private string[] tokens;
        private int pointer;

        public MyIo()
#if  LOCAL_TEST
            : this(new StreamReader("input.txt"))
#else
            : this(System.Console.In)
#endif
        {

        }

        public MyIo(TextReader inputStream)
        {
            this.inputStream = inputStream;
        }

        public char NextChar()
        {
            try
            {
                return (char)inputStream.Read();
            }
            catch (IOException)
            {
                return '\0';
            }
        }

        public string NextLine()
        {
            try
            {
                return inputStream.ReadLine();
            }
            catch (IOException)
            {
                return null;
            }
        }

        public string NextString()
        {
            try
            {
                while (tokens == null || pointer >= tokens.Length)
                {
                    tokens = (NextLine() + string.Empty).Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    pointer = 0;
                }
                return tokens[pointer++];
            }
            catch (IOException)
            {
                return null;
            }
        }

        public int NextInt()
        {
            return Next<int>();
        }

        public long NextLong()
        {
            return Next<long>();
        }

        public T Next<T>()
        {
            var t = typeof(T);

            if (t == typeof(char))
                return (T)(object)NextChar();

            object s = NextString();

            if (t == typeof(string))
                return (T)s;

            return (T)Convert.ChangeType(s, typeof(T));
        }

        public IEnumerable<T> NextWhile<T>(Predicate<T> pred)
        {
            if (pred == null)
                yield break;

            T res = Next<T>();

            while (pred(res))
            {
                yield return res;

                res = Next<T>();
            }
        }

        public IEnumerable<T> NextSeq<T>(long n)
        {
            for (var i = 0; i < n; i++)
                yield return Next<T>();
        }

        public void Print(string format, params object[] args)
        {
            outputStream.Write(string.Format(CultureInfo.InvariantCulture, format, args));
        }

        public void PrintLine(string format, params object[] args)
        {
            Print(format, args);

            outputStream.WriteLine();
        }

        public void Print(bool o)
        {
            Print(o ? "yes" : "no");
        }

        public void PrintLine(bool o)
        {
            Print(o);

            outputStream.WriteLine();
        }

        public void Print<T>(T o)
        {
            outputStream.Write(Convert.ToString(o, CultureInfo.InvariantCulture));
        }

        public void PrintLine<T>(T o)
        {
            Print(o);

            outputStream.WriteLine();
        }

        public void Close()
        {
            inputStream.Close();
            outputStream.Close();
        }

        void IDisposable.Dispose()
        {
            Close();

#if  LOCAL_TEST
            Console.ReadLine();
#endif
        }
    }

    public static class ListExtensions
    {
        public static void Each<T>(this IEnumerable<T> self, Action<T> action)
        {
            foreach (var v in self)
                action(v);
        }

        public static IEnumerable<T> ToCycleEnumerable<T>(this IEnumerable<T> self)
        {
            if (self != null)
            {
                for (; ; )
                {
                    foreach (var x in self)
                        yield return x;
                }
            }
        }

        public static T CycleGet<T>(this IList<T> self, int index)
        {
            var c = self.Count;
            return self[(index % c + c) % c];
        }

        public static IList<T> Shuffle<T>(this IList<T> self)
        {
            var rnd = new Random(DateTime.Now.Millisecond);

            var n = self.Count;

            while (n > 1)
            {
                n--;
                var k = rnd.Next(n + 1);
                var value = self[k];
                self[k] = self[n];
                self[n] = value;
            }

            return self;
        }

        public static IList<IList<T>> UseForNew2D<T>(this T def, int fd, int sd)
        {
            var fdim = new T[fd][];

            for (int i = 0; i < fd; i++)
            {
                fdim[i] = new T[sd];
                Fill(fdim[i], def);
            }

            return fdim;
        }

        public static IList<T> Fill<T>(this IList<T> self, Func<T> fval)
        {
            for (var i = 0; i < self.Count; i++)
                self[i] = fval();

            return self;
        }

        public static IList<T> Fill<T>(this IList<T> self, T val)
        {
            return self.Fill(() => val);
        }

        public static long Hash<T>(this IList<T> self, Func<T, long> val = null)
        {
            return val != null ? self.Hash((t, current) => unchecked(current * 19L + val(t))) : self.Hash(HashOne);
        }

        public static long Hash<T>(this IList<T> self, Func<T, long, long> val)
        {
            return self.Aggregate(0L, (current, t) => unchecked(val(t, current)));
        }

        public static long HashOne<T>(this T self, long current)
        {
            return unchecked(current * 19L + (Equals(self, default(T)) ? 0 : self.GetHashCode()));
        }

        public static IList<T1> BuildSegTree<T1, T2>(this IList<T2> a, Func<T1, T1, T1> combine, Func<T2, T1> convert)
        {
            var t = new T1[a.Count << 2];

            a.BuildSegTree(t, 1, 0, a.Count - 1, combine, convert);

            return t;
        }

        private static void BuildSegTree<T1, T2>(this IList<T2> a, IList<T1> t, int v, int tl, int tr, Func<T1, T1, T1> combine, Func<T2, T1> convert)
        {
            if (tl == tr)
            {
                t[v] = convert(a[tl]);
            }
            else
            {
                int tm = (tl + tr) >> 1;

                BuildSegTree(a, t, v << 1, tl, tm, combine, convert);
                BuildSegTree(a, t, (v << 1) + 1, tm + 1, tr, combine, convert);

                t[v] = combine(t[v << 1], t[(v << 1) + 1]);
            }
        }
    }

    public static class P
    {
        public static P<T1, T2> Create<T1, T2>(T1 key, T2 val)
        {
            return new P<T1, T2>(key, val);
        }
    }

    public class P<T1, T2>
    {
        private class PComparer : IComparer<P<T1, T2>>
        {
            private readonly bool? byKey;

            public PComparer(bool? byKey)
            {
                this.byKey = byKey;
            }

            public int Compare(P<T1, T2> x, P<T1, T2> y)
            {
                x = x ?? new P<T1, T2>();
                y = y ?? new P<T1, T2>();

                if (byKey == true)
                    return Comparer<T1>.Default.Compare(x.Key, y.Key);
                else if (byKey == false)
                    return Comparer<T2>.Default.Compare(x.Value, y.Value);
                else
                {
                    var tr = Comparer<T1>.Default.Compare(x.Key, y.Key);

                    if (tr != 0)
                        tr = Comparer<T2>.Default.Compare(x.Value, y.Value);

                    return tr;
                }
            }
        }

        public P()
        {
        }

        public P(T1 key, T2 val)
        {
            this.Key = key;
            this.Value = val;
        }

        public T1 Key
        {
            get;
            set;
        }

        public T2 Value
        {
            get;
            set;
        }

        public P<T1, T2> Clone()
        {
            return new P<T1, T2>(Key, Value);
        }

        public static IComparer<P<T1, T2>> KeyComparer
        {
            get { return new PComparer(true); }
        }

        public static IComparer<P<T1, T2>> ValueComparer
        {
            get { return new PComparer(false); }
        }

        public static implicit operator T1(P<T1, T2> obj)
        {
            return obj.Key;
        }

        public static implicit operator T2(P<T1, T2> obj)
        {
            return obj.Value;
        }

        public P<T1, T2> SetKey(T1 key)
        {
            Key = key;
            return this;
        }

        public P<T1, T2> SetValue(T2 value)
        {
            Value = value;
            return this;
        }

        public override string ToString()
        {
            return string.Format("Key: {0}, Value: {1}", Key, Value);
        }

        public override bool Equals(object obj)
        {
            var co = obj as P<T1, T2>;

            return co != null && co.GetHashCode() == GetHashCode();
        }

        public override int GetHashCode()
        {
            int hash = 17;
            hash = hash * 31 + ((Equals(Key, default(T1))) ? 0 : Key.GetHashCode());
            hash = hash * 31 + ((Equals(Value, default(T1))) ? 0 : Value.GetHashCode());
            return hash;

        }
    }

    #endregion

    internal class Program
    {
        #region Program

        private readonly MyIo io;

        public Program(MyIo io)
        {
            this.io = io;
        }

        public static void Main(string[] args)
        {
            using (MyIo io = new MyIo())
            {
                new Program(io)
                    .Solve();
            }
        }

        #endregion
        public const long MOD = 1000000007;
        public const double EPS = 1e-14;

        private void Solve()
        {
            var a = io.NextLong();
            var b = io.NextLong();

            io.Print(Calc(b) - Calc(a-1));
        }

        private long Calc(long a)
        {
            var al = (long)Math.Log10(a) + 1;

            if (al == 1)
                return a;
            else
            {
                var dgts = new long[al];

                var xa = a;

                for (int i = 0; i < al; i++)
                {
                    dgts[al- i -1] = xa % 10;
                    xa = xa / 10;
                }

                long res = (long)Math.Pow(10, al - 2) * (dgts[0] - 1) + 9;

                for (int i = 2; i < al ; i++)
                    res += (long)Math.Pow(10, i - 2) * 9;

                if (al < 2)
                    res++;
                else
                    res += (a % (long)Math.Pow(10, al - 1))/10 + 1;

                if (dgts[0] > dgts[al - 1])
                    res--;

                return res;
            }
        }
    }

}


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

class Program
{
    static TextReader reader;
    static TextWriter writer;
    const double EPS = 1e-7;
    static Program()
    {
#if ONLINE_JUDGE
                reader = Console.In;
                writer = Console.Out;
#else
        reader = new StreamReader("input.txt");
        writer = new StreamWriter("output.txt");
#endif
    }
    static long gcd(long a, long b)
    {
        return (b != 0) ? gcd(b, a % b) : a;
    }
    static void swap(ref int a, ref int b)
    {
        int t = a;
        a = b;
        b = t;
    }
    static long pow(long a, long x, long mod)
    {
        long res = 1;
        while (x > 0)
        {
            if ((x & 1) == 1)
            {
                res = (res * a) % mod;
                --x;
            }
            else
            {
                a = (a * a) % mod;
                x >>= 1;
            }
        }
        return res;
    }
    struct C
    {
        public long x, y;
        public C(long c, long d)
        {
            x = c;
            y = d;
        }
    }
    struct Pair<T>
    {
        public T first, second;
        public Pair(T f, T s)
        {
            first = f;
            second = s;
        }
    }
    static void _a()
    {

    }
    static void _b()
    {

    }
    static long f(long x)
    {
        long ans = Math.Min(x,9), len = (long)Math.Log10(x) + 1, p = (long)Math.Pow(10, len - 1), xf = x / p, xl = x % 10;
        for (int l = 2; l <= len; ++l)
        {
            for (int i = 1; i <= 9; ++i)
            {
                if (l < len || i < xf)
                    ans += (long)Math.Pow(10, l - 2);
                else
                {
                    ans += (x - x / p * p) / 10;
                    if (i <= xl)
                        ++ans;
                    break;
                }
            }
        }
        return ans;
    }
    static void _c()
    {
        string[] lr = reader.ReadLine().Split();
        long l = long.Parse(lr[0]), r = long.Parse(lr[1]), ans = 0;
        writer.Write(f(r) - f(l-1));
    }
    static void _d()
    {

    }
    static void Main(string[] args)
    {
        _c();
        reader.Close();
        writer.Close();
    }
}


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

namespace AlgoTasks
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            int[] y = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();

            if (x.Sum() >= y.Sum())
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

        }
    }
}


using System;

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            int w = Convert.ToInt32(Console.ReadLine()); // input
            string line1, line2;
            string[] splitted;
            int[] pile1 = new int[w];
            int[] pile2 = new int[w];
            line1 = Console.ReadLine();
            splitted = line1.Split(" ");
            for (int j = 0; j < w; j++)
            {
                pile1[j] = Convert.ToInt32(splitted[j]);
            }
            line2 = Console.ReadLine();
            splitted = line2.Split(" ");
            for (int j = 0; j < w; j++)
            {
                pile2[j] = Convert.ToInt32(splitted[j]);
            }
            if (IsPossible(pile1, pile2))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }

        static bool IsPossible(int[] a, int[] b)
        {
            int sum1 = 0;
            int sum2 = 0;
            for (int i = 0; i < a.Length; i++)
            {
                sum1 += a[i];
                sum2 += b[i];
            }
            return sum1 >= sum2;

        }

    }
}


using System;
using System.Linq;
using static System.Console;
class Solution
{
    static void Main(string[] args)
    {
        ReadLine();
        int[] a = Array.ConvertAll(ReadLine().Split(), int.Parse);
        int[] b = Array.ConvertAll(ReadLine().Split(), int.Parse);
        WriteLine(a.Sum()>=b.Sum()?"Yes":"No");

    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] y = Console.ReadLine().Split(' ');
            string[] y1 = Console.ReadLine().Split(' ');
            int sum = 0;
            int sum1 = 0;
            for (int i = 0; i < y.Length; i++)
            {
                sum += int.Parse(y[i]);
            }
            for (int i = 0; i < y1.Length; i++)
            {
                sum1 += int.Parse(y1[i]);
            }
            if (sum >= sum1)
                Console.Write("YES");
            else
                Console.Write("NO");
        }
    }
}


using System;
using System.Collections.Generic;
class some
{
	public static void Main()
	{
		Console.ReadLine();
		string[]ss=Console.ReadLine().Split();
		string[]ss1=Console.ReadLine().Split();
		int sum1=0;int sum2=0;
		foreach(string cc in ss)sum1+=int.Parse(cc);
		foreach(string cc in ss1)sum2+=int.Parse(cc);
		if(sum1>=sum2)Console.WriteLine("Yes");
		else Console.WriteLine("No");
	}
}


// Problem: 1013A - Piles With Stones
// Author: Gusztav Szmolik

using System;

class PilesWithStones
    {
    public static int Main ()
        {
        string line = Console.ReadLine ();
        if (line == null)
            return -1;
        string[] words = line.Split ();
        if (words.Length != 1)
            return -1;
        byte n;
        if (!Byte.TryParse (words[0], out n))
            return -1;
        if (n < 1 || n > 50)
            return -1;
        line = Console.ReadLine ();
        if (line == null)
            return -1;
        words = line.Split ();
        if (words.Length != n)
            return -1;
        ushort sumX = 0;
        for (byte i = 0; i < n; i++)
            {
            ushort x;
            if (!UInt16.TryParse (words[i], out x))
                return -1;
            if (x > 1000)
                return -1;
            sumX += x;
            }
        line = Console.ReadLine ();
        if (line == null)
            return -1;
        words = line.Split ();
        if (words.Length != n)
            return -1;
        ushort sumY = 0;
        for (byte i = 0; i < n; i++)
            {
            ushort y;
            if (!UInt16.TryParse (words[i], out y))
                return -1;
            if (y > 1000)
                return -1;
            sumY += y;
            }
        Console.WriteLine (sumX < sumY ? "No" : "Yes");
        return 0;
        }
    }


using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine();
            var s = Console.ReadLine().Split();
            var s1 = Console.ReadLine().Split();
            int sum1=0, sum2=0;
            foreach (var i in s)
            {
                sum1 += Convert.ToInt32(i);
            }

            foreach (var i in s1)
            {
                sum2 += Convert.ToInt32(i);
            }
            if(sum1>=sum2)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
            Console.ReadLine();
        }
    }
}


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

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

          string[] token1 = Console.ReadLine().Split();
          string[] token2 = Console.ReadLine().Split();

          int sum1 = 0,sum2 = 0;

          for(int i=0;i<token1.Length;i++){
             sum1 += int.Parse(token1[i]);
             sum2 += int.Parse(token2[i]);
          }

          if(sum2>sum1)Console.WriteLine("No");
          else Console.WriteLine("Yes");

        }
    }
}


using System;
using System.Linq;

namespace CS_CodeForces
{
    internal class Program
    {
        private static void Main()
        {
            ScanInt();
            Console.Write(ScanIntArray().Sum() >= ScanIntArray().Sum() ? "Yes" : "No");
        }

        // Extensions
        public static string ScanStr()
        {
            return Console.ReadLine();
        }

        public static int ScanInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] ScanIntArray()
        {
            string[] inp = Console.ReadLine().Split(' ');
            int[] arr = new int[inp.Length];
            for (int i = 0; i < inp.Length; i++)
            {
                arr[i] = int.Parse(inp[i]);
            }

            return arr;
        }
    }
}


using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] y = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(x.Sum() >= y.Sum() ? "Yes" : "No");
    }
}


using System;
using System.Linq;

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            int str1 = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray().Sum();
            int str2 = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray().Sum();

                Console.WriteLine(str2>str1?"NO":"YES");
        }
    }
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int totNums = Convert.ToInt32(Console.ReadLine());
            string inp;string[] arr;

            int a = 0, b = 0;
            inp = Console.ReadLine();arr = inp.Split(' ');
            for (int i = 0; i < totNums; i++)
                a += Convert.ToInt32(arr[i]);
            inp = Console.ReadLine();arr = inp.Split(' ');
            for (int i = 0; i < totNums; i++)
                b += Convert.ToInt32(arr[i]);

            if (a >= b) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


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

namespace C_Sharp_Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = II(), a = 0, b = 0;
            for (int i = 0; i < n; ++i) a += II();
            for (int i = 0; i < n; ++i) b += II();
            Console.WriteLine(a >= b ? "Yes" : "No");
        }

        private static int II()
        {
            int num = 0;
            bool sign = true;
            char c = getChar();
            while (!((c >= '0' && c <= '9') || c == '-')) c = getChar();
            if (c == '-')
            {
                sign = false;
                c = getChar();
            }
            while (c >= '0' && c <= '9')
            {
                num = (num << 1) + (num << 3) + c - '0';
                c = getChar();
            }
            return sign ? num : -num;
        }
        private static char getChar()
        {
            return (char)Console.Read();
        }
    }
}


using System;
class Program
{
    static void Main()
    {
        int n = Convert.ToInt32(Console.ReadLine());
        int[] Fday = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
        int[] Sday = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
        int sum0 = 0, sum1 = 0;
        foreach (int i in Fday)
        {
            sum0 += i;
        }
        foreach (int i in Sday)
        {
            sum1 += i;
        }
        Console.WriteLine(sum0 >= sum1 ? "Yes" : "No");
    }
}


using System;

namespace Codeforces {
    class Program {
        static void Main(string[] args) {
            Console.ReadLine();
            string[] day1 = Console.ReadLine().Split(' ');
            string[] day2 = Console.ReadLine().Split(' ');
            long sum1 = 0, sum2 = 0;
            foreach (string n in day1) {
                sum1 += long.Parse(n);
            }
            foreach (string n in day2) {
                sum2 += long.Parse(n);
            }
            if (sum1 >= sum2) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
class Problem
{
    static void Main()
    {
        //--------------------------------input--------------------------------//

        int n = Convert.ToInt32( Console.ReadLine() );
        var a = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );
        var b = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );

        //--------------------------------solve--------------------------------/

        int sum = a.Sum();
        sum -= b.Sum();
        if(sum >= 0)
            Console.WriteLine( "Yes" );
        else
            Console.WriteLine( "No" );

    }

}


using System;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());

            string s1 = Console.ReadLine();
            string s2 = Console.ReadLine();

            int[] a = new int[10001];
            int[] b = new int[10001];

            int kol1 = 0;
            for(int i = 0; i<n-1; i++)
            {
                int k = s1.IndexOf(" ");
                a[i] = Convert.ToInt32(s1.Remove(k, s1.Length - k));
                s1 = s1.Remove(0, k + 1);
                kol1 += a[i];
            }
            a[n] = Convert.ToInt32(s1);
            kol1 += a[n];
            int kol2 = 0;
            for (int i = 0; i < n - 1; i++)
            {
                int k = s2.IndexOf(" ");
                b[i] = Convert.ToInt32(s2.Remove(k, s2.Length - k));
                s2 = s2.Remove(0, k + 1);
                kol2 += b[i];
            }
            b[n] = Convert.ToInt32(s2);
            kol2 += b[n];
            if (kol1 < kol2)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
    }
}


using System;
using System.Linq;

namespace CSharp
{
    public class _1013A
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(token => int.Parse(token)).ToArray();
            int[] y = Console.ReadLine().Split().Select(token => int.Parse(token)).ToArray();

            Console.WriteLine(x.Sum() >= y.Sum() ? "Yes" : "No");
        }
    }
}


using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
class Problem
{
    static void Main()
    {
        //--------------------------------input--------------------------------//

        int n = Convert.ToInt32( Console.ReadLine() );
        var a = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );
        var b = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );

        //--------------------------------solve--------------------------------/

        int sum = a.Sum();
        sum -= b.Sum();
        if(sum == 0)
            Console.WriteLine( "Yes" );
        else
            Console.WriteLine( "No" );

    }

}


using System;
class Program
{
    static void Main()
    {
        int n = Convert.ToInt32(Console.ReadLine());
        int[] Fday = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
        int[] Sday = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
        int sum0 = 0, sum1 = 0;
        foreach (int i in Fday)
        {
            sum0 += i;
        }
        foreach (int i in Sday)
        {
            sum1 += i;
        }
        Console.WriteLine(sum0 <= sum1 ? "Yes" : "No");
    }
}


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

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

          string[] token1 = Console.ReadLine().Split();
          string[] token2 = Console.ReadLine().Split();

          int sum1 = 0,sum2 = 0;

          for(int i=0;i<token1.Length;i++){
             sum1 += int.Parse(token1[0]);
             sum2 += int.Parse(token2[1]);
          }

          if(sum2>sum1)Console.WriteLine("No");
          else Console.WriteLine("Yes");

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Numerics;
using E = System.Linq.Enumerable;

namespace Prob13 {
    class Program {
        protected IOHelper io;

        public Program(string inputFile, string outputFile) {
            io = new IOHelper(inputFile, outputFile, Encoding.Default);

            long n = long.Parse(io.NextToken());
            n %= 360;
            if (n < 0) n += 360;
            if (n >= 315) {
                n = 0;
            }
            int ans = (int)((n - 45 + 89) / 90);
            ans %= 4;
            io.WriteLine(ans);

            io.Dispose();
        }

        static void Main(string[] args) {
            Program myProgram = new Program(null, null);
        }
    }

    class IOHelper : IDisposable {
        public StreamReader reader;
        public StreamWriter writer;

        public IOHelper(string inputFile, string outputFile, Encoding encoding) {
            if (inputFile == null)
                reader = new StreamReader(Console.OpenStandardInput(), encoding);
            else
                reader = new StreamReader(inputFile, encoding);

            if (outputFile == null)
                writer = new StreamWriter(Console.OpenStandardOutput(), encoding);
            else
                writer = new StreamWriter(outputFile, false, encoding);

            curLine = new string[] { };
            curTokenIdx = 0;
        }

        string[] curLine;
        int curTokenIdx;

        char[] whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        public bool hasNext() {
            if (curTokenIdx >= curLine.Length) {
                //Read next line
                string line = reader.ReadLine();
                if (line != null)
                    curLine = line.Split(whiteSpaces, StringSplitOptions.RemoveEmptyEntries);
                else
                    curLine = new string[] { };
                curTokenIdx = 0;
            }

            return curTokenIdx < curLine.Length;
        }

        public string NextToken() {
            return hasNext() ? curLine[curTokenIdx++] : null;
        }

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

        public double NextDouble() {
            string tkn = NextToken();
            return double.Parse(tkn, System.Globalization.CultureInfo.InvariantCulture);
        }

        public void Write(double val, int precision) {
            writer.Write(val.ToString("F" + precision, System.Globalization.CultureInfo.InvariantCulture));
        }

        public void Write(object stringToWrite) {
            writer.Write(stringToWrite);
        }

        public void WriteLine(double val, int precision) {
            writer.WriteLine(val.ToString("F" + precision, System.Globalization.CultureInfo.InvariantCulture));
        }

        public void WriteLine(object stringToWrite) {
            writer.WriteLine(stringToWrite);
        }

        public void Dispose() {
            try {
                if (reader != null) {
                    reader.Dispose();
                }
                if (writer != null) {
                    writer.Flush();
                    writer.Dispose();
                }
            } catch { };
        }

        public void Flush() {
            if (writer != null) {
                writer.Flush();
            }
        }
    }
}


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

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

        private static void Main(string[] args)
        {
            long n = long.Parse(reader.ReadLine());

            n %= 360;

            if (n >= 0)
            {
                if (n <= 45)
                    writer.WriteLine("0");
                else if (n <= 45 + 90)
                    writer.WriteLine("1");
                else if (n <= 45 + 180)
                    writer.WriteLine("2");
                else if (n < 45 + 270)
                    writer.WriteLine("3");
                else
                {
                    writer.WriteLine("0");
                }
            }
            else
            {
                if (n >= -45)
                    writer.WriteLine("0");
                else if (n > -45 - 90)
                    writer.WriteLine("3");
                else if (n > -45 - 180)
                    writer.WriteLine("2");
                else if (n > -45 - 270)
                    writer.WriteLine("1");
                else
                {
                    writer.WriteLine("0");
                }
            }

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


using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Threading;
using System.Diagnostics;
using System.Linq;
using System.Globalization;

class Solution
{
    public TextInput cin;
    public TextOutput cout;
    public TextOutput cerr;

    public long Dist(long x)
    {
        x = x % 360L;
        return Math.Min(Math.Abs(x), 360 - Math.Abs(x));
    }
    public void Solve()
    {
        var n = (cin.Read<long>()) % 360L;
        var min = 0L;
        for (var i = 1L; i <= 4; i++)
        {
            var x = Dist(min * 90L - n);
            var y = Dist(i * 90L - n);
            if (y < x)
            {
                min = i;
            }
        }
        cout.WriteLine(min);
    }
}

#region Core
static class Program
{
    public static readonly TextInput cin = new TextInput(Console.In);
    public static readonly TextOutput cout = new TextOutput(Console.Out);
    public static readonly TextOutput cerr = new TextOutput(Console.Error);
#if !DEBUG
    static void Main()
    {
        new Solution
        {
            cin = cin,
            cout = cout,
            cerr = cerr
        }.Solve();
    }
#endif
}
public class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
{
    public new TValue this[TKey key]
    {
        get
        {
            TValue res;
            base.TryGetValue(key, out res);
            return res;
        }
        set
        {
            base[key] = value;
        }
    }
}
public static class Ext
{

    #region Prewriten
    public static void Foreach<T>(this IEnumerable<T> elements, Action<T> action)
    {
        foreach(var element in elements)
        {
            action(element);
        }
    }
    public static void Foreach<T>(this IEnumerable<T> elements, Action<T, int> action)
    {
        var index = 0;
        foreach(var element in elements)
        {
            action(element, index++);
        }
    }
    public static IEnumerable<T> Init<T>(int n) where T : new()
    {
        for (var i = 0; i < n; i++)
        {
            yield return new T();
        }
    }
    public static IEnumerable<T> Init<T>(int n, T defaultValue = default(T))
    {
        for (var i = 0; i < n; i++)
        {
            yield return defaultValue;
        }
    }
    public static IEnumerable<T> Init<T>(int n, Func<int, T> builder)
    {
        for (var i = 0; i < n; i++)
        {
            yield return builder(i);
        }
    }
    public static bool IsEmpty(this string s)
    {
        return string.IsNullOrEmpty(s);
    }
    public static string Safe(this string s)
    {
        return s.IsEmpty() ? string.Empty : s;
    }
    public static void Swap<T>(ref T a, ref T b)
    {
        T c = a;
        a = b;
        b = c;
    }
    public static long Gcd(long a, long b)
    {
        while (a > 0)
        {
            b %= a;
            Swap(ref a, ref b);
        }
        return b;
    }
    public static int[] ZFunction(string s)
    {
        var z = new int[s.Length];
        for (int i = 1, l = 0, r = 0; i < s.Length; ++i)
        {
            if (i <= r)
            {
                z[i] = Math.Min(r - i + 1, z[i - l]);
            }
            while (i + z[i] < s.Length && s[z[i]] == s[i + z[i]])
            {
                z[i]++;
            }
            if (i + z[i] - 1 > r)
            {
                l = i;
                r = i + z[i] - 1;
            }
        }
        return z;
    }
    public static long Pow(long a, long p)
    {
        var b = 1L;
        while (p > 0)
        {
            if ((p & 1) == 0)
            {
                a *= a;
                p >>= 1;
            }
            else
            {
                b *= a;
                p--;
            }
        }
        return b;
    }
    #endregion
}

public delegate bool TryParseDelegate<T>(string s, NumberStyles style, IFormatProvider format, out T value);
public class TextInput
{
    private static Dictionary<Type, Delegate> primitiveParsers = new Dictionary<Type, Delegate>
        {
            { typeof(sbyte), new TryParseDelegate<sbyte>(sbyte.TryParse) },
            { typeof(short), new TryParseDelegate<short>(short.TryParse) },
            { typeof(int),  new TryParseDelegate<int>(int.TryParse) },
            { typeof(long), new TryParseDelegate<long>(long.TryParse) },

            { typeof(byte), new TryParseDelegate<byte>(byte.TryParse) },
            { typeof(ushort), new TryParseDelegate<ushort>(ushort.TryParse) },
            { typeof(uint), new TryParseDelegate<uint>(uint.TryParse) },
            { typeof(ulong), new TryParseDelegate<ulong>(ulong.TryParse) },

            { typeof(float), new TryParseDelegate<float>(float.TryParse) },
            { typeof(double), new TryParseDelegate<double>(double.TryParse) },
            { typeof(decimal), new TryParseDelegate<decimal>(decimal.TryParse) },

            { typeof(char), new TryParseDelegate<char>(CharParser) },
            { typeof(string), new TryParseDelegate<string>(StringParser) }
        };
    private static bool CharParser(string s, NumberStyles style, IFormatProvider format, out char res)
    {
        res = char.MinValue;
        if (string.IsNullOrEmpty(s))
        {
            return false;
        }
        else
        {
            res = s[0];
            return true;
        }
    }
    private static bool StringParser(string s, NumberStyles style, IFormatProvider format, out string res)
    {
        res = s == null ? string.Empty : s;
        return true;
    }

    private string line = null;
    private int pos = 0;

    public IFormatProvider FormatProvider { get; set; }
    public NumberStyles NumberStyle { get; set; }
    public TextReader TextReader { get; set; }

    public TextInput(string path) : this(path, NumberStyles.Any, CultureInfo.InvariantCulture)
    {
    }
    public TextInput(string path, NumberStyles numberStyle, IFormatProvider formatProvider) : this(new StreamReader(path), numberStyle, formatProvider)
    {

    }
    public TextInput(TextReader textReader) : this(textReader, NumberStyles.Any, CultureInfo.InvariantCulture)
    {

    }
    public TextInput(TextReader textReader, NumberStyles numberStyle, IFormatProvider formatProvider)
    {
        TextReader = textReader;
        NumberStyle = numberStyle;
        FormatProvider = formatProvider;
    }

    public bool IsEof
    {
        get
        {
            return line == null && TextReader.Peek() == -1;
        }
    }
    public void SkipWhiteSpace()
    {
        while (!IsEof)
        {
            if (line != null && pos < line.Length && !char.IsWhiteSpace(line[pos]))
            {
                return;
            }
            if (line == null || pos >= line.Length)
            {
                Next();
                continue;
            }
            while (pos < line.Length && char.IsWhiteSpace(line[pos]))
            {
                pos++;
            }
        }
    }
    private void SkipWhiteSpace(bool force)
    {
        if (force)
        {
            SkipWhiteSpace();
        }
        else
        {
            SkipWhiteSpace();
        }
    }

    public T[] ReadArray<T>()
    {
        var length = Read<int>();
        return ReadArray<T>(length);
    }
    public T[] ReadArray<T>(int length)
    {
        var array = new T[length];

        var parser = GetParser<T>();
        var style = NumberStyle;
        var format = FormatProvider;

        for (var i = 0; i < length; i++)
        {
            array[i] = Read<T>(parser, style, format);
        }
        return array;
    }

    public bool TryReadArray<T>(out T[] array)
    {
        return TryReadArray<T>(GetParser<T>(), NumberStyle, FormatProvider, out array);
    }
    public bool TryReadArray<T>(out T[] array, int length)
    {
        return TryReadArray<T>(GetParser<T>(), NumberStyle, FormatProvider, out array, length);
    }
    public bool TryReadArray<T>(T[] array, int offset, int length)
    {
        return TryReadArray<T>(GetParser<T>(), NumberStyle, FormatProvider, array, offset, length);
    }
    public bool TryReadArray<T>(TryParseDelegate<T> parser, NumberStyles style, IFormatProvider format, out T[] array)
    {
        var length = 0;
        if (!TryRead<int>(out length))
        {
            array = null;
            return false;
        }
        array = new T[length];
        return TryReadArray<T>(parser, style, format, array, 0, length);
    }
    public bool TryReadArray<T>(TryParseDelegate<T> parser, NumberStyles style, IFormatProvider format, out T[] array, int length)
    {
        array = new T[length];
        return TryReadArray<T>(parser, style, format, array, 0, length);
    }
    public bool TryReadArray<T>(TryParseDelegate<T> parser, NumberStyles style, IFormatProvider format, T[] array, int offset, int length)
    {
        var result = true;
        for (var i = 0; i < length && result; i++)
        {
            result &= TryRead<T>(parser, style, format, out array[offset + i]);
        }
        return result;
    }

    private TryParseDelegate<T> GetParser<T>()
    {
        var type = typeof(T);
        return (TryParseDelegate<T>)primitiveParsers[type];
    }
    public T Read<T>()
    {
        return Read<T>(GetParser<T>());
    }
    public T Read<T>(NumberStyles style, IFormatProvider format)
    {
        return Read<T>(GetParser<T>(), style, format);
    }
    public T Read<T>(TryParseDelegate<T> parser)
    {
        return Read<T>(parser, NumberStyle, FormatProvider);
    }
    public T Read<T>(TryParseDelegate<T> parser, NumberStyles style, IFormatProvider format)
    {
        T result;
        if (!TryRead(parser, style, format, out result))
        {
            throw new FormatException();
        }
        return result;
    }
    public bool TryRead<T>(out T value)
    {
        return TryRead(GetParser<T>(), out value);
    }
    public bool TryRead<T>(NumberStyles style, IFormatProvider format, out T value)
    {
        return TryRead(GetParser<T>(), style, format, out value);
    }
    public bool TryRead<T>(TryParseDelegate<T> parser, out T value)
    {
        return parser(ReadToken(), NumberStyle, FormatProvider, out value);
    }
    public bool TryRead<T>(TryParseDelegate<T> parser, NumberStyles style, IFormatProvider format, out T value)
    {
        return parser(ReadToken(), style, format, out value);
    }
    public string ReadToken()
    {
        SkipWhiteSpace(false);
        if (IsEof)
        {
            throw new EndOfStreamException();
        }

        if (pos >= line.Length || char.IsWhiteSpace(line[pos])) return string.Empty;

        var start = pos;
        while (pos < line.Length && !char.IsWhiteSpace(line[pos]))
        {
            pos++;
        }
        return line.Substring(start, pos - start);
    }
    public string ReadLine()
    {
        if (IsEof)
        {
            throw new EndOfStreamException();
        }
        if (line == null || pos >= line.Length)
        {
            Next();
        }

        var ans = line.Substring(pos);
        pos = line.Length;
        return ans;
    }

    private void Next()
    {
        line = TextReader.ReadLine();
        pos = 0;
    }
}

public class TextOutput
{
    public IFormatProvider FormatProvider { get; set; }
    public TextWriter TextWriter { get; set; }

    public TextOutput(string path) : this(path, CultureInfo.InvariantCulture)
    {
    }
    public TextOutput(string path, IFormatProvider formatProvider) : this(new StreamWriter(path), formatProvider)
    {

    }
    public TextOutput(TextWriter textWriter) : this(textWriter, CultureInfo.InvariantCulture)
    {

    }
    public TextOutput(TextWriter textWriter, IFormatProvider formatProvider)
    {
        TextWriter = textWriter;
        FormatProvider = formatProvider;
    }

    public TextOutput WriteArray<T>(params T[] array)
    {
        return WriteArray(array, true);
    }
    public TextOutput WriteArray<T>(T[] array, bool appendLine)
    {
        return WriteArray(array, 0, array.Length, appendLine);
    }
    public TextOutput WriteArray<T>(T[] array, int offset, int length, bool appendLine = true)
    {
        var sb = new StringBuilder();
        for (var i = 0; i < length; i++)
        {
            sb.Append(Convert.ToString(array[offset + i], FormatProvider));
            if (i + 1 < length)
            {
                sb.Append(' ');
            }
        }
        return appendLine ? WriteLine(sb.ToString()) : Write(sb.ToString());
    }

    public TextOutput WriteLine(object obj)
    {
        return WriteLine(Convert.ToString(obj, FormatProvider));
    }
    public TextOutput WriteLine(string text, params object[] args)
    {
        return WriteLine(string.Format(FormatProvider, text, args));
    }
    public TextOutput WriteLine(string text)
    {
        TextWriter.WriteLine(text);
        return this;
    }
    public TextOutput WriteLine(char[] buffer)
    {
        TextWriter.WriteLine(buffer);
        return this;
    }
    public TextOutput WriteLine(char[] buffer, int offset, int length)
    {
        TextWriter.WriteLine(buffer, offset, length);
        return this;
    }
    public TextOutput WriteLine()
    {
        TextWriter.WriteLine();
        return this;
    }

    public TextOutput Write(object obj)
    {
        return Write(Convert.ToString(obj, FormatProvider));
    }
    public TextOutput Write(string text, params object[] args)
    {
        return Write(string.Format(FormatProvider, text, args));
    }
    public TextOutput Write(string text)
    {
        TextWriter.Write(text);
        return this;
    }
    public TextOutput Write(char[] buffer)
    {
        TextWriter.Write(buffer);
        return this;
    }
    public TextOutput Write(char[] buffer, int offset, int length)
    {
        TextWriter.Write(buffer, offset, length);
        return this;
    }
}
#endregion


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Numerics;
using E = System.Linq.Enumerable;

namespace Prob13 {
    class Program {
        protected IOHelper io;

        public Program(string inputFile, string outputFile) {
            io = new IOHelper(inputFile, outputFile, Encoding.Default);

            long n = long.Parse(io.NextToken());
            n %= 360;
            if (n >= 315) {
                n = 0;
            }
            if (n < 0) n += 360;
            int ans = (int)((n - 45 + 89) / 90);
            ans %= 4;
            io.WriteLine(ans);

            io.Dispose();
        }

        static void Main(string[] args) {
            Program myProgram = new Program(null, null);
        }
    }

    class IOHelper : IDisposable {
        public StreamReader reader;
        public StreamWriter writer;

        public IOHelper(string inputFile, string outputFile, Encoding encoding) {
            if (inputFile == null)
                reader = new StreamReader(Console.OpenStandardInput(), encoding);
            else
                reader = new StreamReader(inputFile, encoding);

            if (outputFile == null)
                writer = new StreamWriter(Console.OpenStandardOutput(), encoding);
            else
                writer = new StreamWriter(outputFile, false, encoding);

            curLine = new string[] { };
            curTokenIdx = 0;
        }

        string[] curLine;
        int curTokenIdx;

        char[] whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        public bool hasNext() {
            if (curTokenIdx >= curLine.Length) {
                //Read next line
                string line = reader.ReadLine();
                if (line != null)
                    curLine = line.Split(whiteSpaces, StringSplitOptions.RemoveEmptyEntries);
                else
                    curLine = new string[] { };
                curTokenIdx = 0;
            }

            return curTokenIdx < curLine.Length;
        }

        public string NextToken() {
            return hasNext() ? curLine[curTokenIdx++] : null;
        }

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

        public double NextDouble() {
            string tkn = NextToken();
            return double.Parse(tkn, System.Globalization.CultureInfo.InvariantCulture);
        }

        public void Write(double val, int precision) {
            writer.Write(val.ToString("F" + precision, System.Globalization.CultureInfo.InvariantCulture));
        }

        public void Write(object stringToWrite) {
            writer.Write(stringToWrite);
        }

        public void WriteLine(double val, int precision) {
            writer.WriteLine(val.ToString("F" + precision, System.Globalization.CultureInfo.InvariantCulture));
        }

        public void WriteLine(object stringToWrite) {
            writer.WriteLine(stringToWrite);
        }

        public void Dispose() {
            try {
                if (reader != null) {
                    reader.Dispose();
                }
                if (writer != null) {
                    writer.Flush();
                    writer.Dispose();
                }
            } catch { };
        }

        public void Flush() {
            if (writer != null) {
                writer.Flush();
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Numerics;
using E = System.Linq.Enumerable;

namespace Prob13 {
    class Program {
        protected IOHelper io;

        public Program(string inputFile, string outputFile) {
            io = new IOHelper(inputFile, outputFile, Encoding.Default);

            long n = long.Parse(io.NextToken());
            n %= 360;
            if (n < 0) n += 360;
            int ans = (int)((n - 45 + 89) / 90);
            ans %= 4;
            io.WriteLine(ans);

            io.Dispose();
        }

        static void Main(string[] args) {
            Program myProgram = new Program(null, null);
        }
    }

    class IOHelper : IDisposable {
        public StreamReader reader;
        public StreamWriter writer;

        public IOHelper(string inputFile, string outputFile, Encoding encoding) {
            if (inputFile == null)
                reader = new StreamReader(Console.OpenStandardInput(), encoding);
            else
                reader = new StreamReader(inputFile, encoding);

            if (outputFile == null)
                writer = new StreamWriter(Console.OpenStandardOutput(), encoding);
            else
                writer = new StreamWriter(outputFile, false, encoding);

            curLine = new string[] { };
            curTokenIdx = 0;
        }

        string[] curLine;
        int curTokenIdx;

        char[] whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        public bool hasNext() {
            if (curTokenIdx >= curLine.Length) {
                //Read next line
                string line = reader.ReadLine();
                if (line != null)
                    curLine = line.Split(whiteSpaces, StringSplitOptions.RemoveEmptyEntries);
                else
                    curLine = new string[] { };
                curTokenIdx = 0;
            }

            return curTokenIdx < curLine.Length;
        }

        public string NextToken() {
            return hasNext() ? curLine[curTokenIdx++] : null;
        }

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

        public double NextDouble() {
            string tkn = NextToken();
            return double.Parse(tkn, System.Globalization.CultureInfo.InvariantCulture);
        }

        public void Write(double val, int precision) {
            writer.Write(val.ToString("F" + precision, System.Globalization.CultureInfo.InvariantCulture));
        }

        public void Write(object stringToWrite) {
            writer.Write(stringToWrite);
        }

        public void WriteLine(double val, int precision) {
            writer.WriteLine(val.ToString("F" + precision, System.Globalization.CultureInfo.InvariantCulture));
        }

        public void WriteLine(object stringToWrite) {
            writer.WriteLine(stringToWrite);
        }

        public void Dispose() {
            try {
                if (reader != null) {
                    reader.Dispose();
                }
                if (writer != null) {
                    writer.Flush();
                    writer.Dispose();
                }
            } catch { };
        }

        public void Flush() {
            if (writer != null) {
                writer.Flush();
            }
        }
    }
}


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

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

        private static void Main(string[] args)
        {
            long n = long.Parse(reader.ReadLine());

            n %= 360;

            if (n >= 0)
            {
                if (n <= 45)
                    writer.WriteLine("0");
                else if (n <= 45 + 90)
                    writer.WriteLine("1");
                else if (n <= 45 + 180)
                    writer.WriteLine("2");
                else
                    writer.WriteLine("3");
            }
            else
            {
                if (n >= -45)
                    writer.WriteLine("0");
                else if (n > -45 - 90)
                    writer.WriteLine("3");
                else if (n > -45 - 180)
                    writer.WriteLine("2");
                else
                    writer.WriteLine("1");
            }

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


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Numerics;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
using static AtCoder.CalcL;
namespace AtCoder
{
    class AC
    {
        //const int MOD = 1000000007;
        const int MOD = 998244353;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dI = { 0, 1, 0, -1 };
        static readonly int[] dJ = { 1, 0, -1, 0 };
        static List<List<int>> G = new List<List<int>>();
        //List<List<Edge>> G = new List<List<Edge>>();
        //static List<Edge> E = new List<Edge>();
        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            //var t = int.Parse(Console.ReadLine());
            for(var _ = 0; _ < 1; _++)
            {
                var input = cin.ReadSplitInt();
                int n = input[0];
                int m = input[1];
                if (m < n - 1)
                {
                    Console.WriteLine(0);
                    return;
                }
                var md = new Modulo(m + 10, MOD);
                long ans = 0;
                for(var k = n - 1; k <= m; k++)
                {
                    ans += md.Mul(md.Pow(2, n - 3), md.Mul(md.Ncr(k - 1, n - 2), (n - 2)));
                    ans %= MOD;
                }
                Console.WriteLine(ans);
            }

            //Console.Out.Flush();
        }
        struct Edge
        {
            public int from;

            public int to;
            public long dist;
            public Edge(int t, long c)
            {
                from = -1;
                to = t;
                dist = c;
            }
            public Edge(int f, int t, long c)
            {
                from = f;
                to = t;
                dist = c;
            }

        }
    }

    public class Scanner
    {
        public int[] ReadSplitInt()
        {
            return ConvertAll(Console.ReadLine().Split(), int.Parse);
        }
        public long[] ReadSplitLong()
        {
            return ConvertAll(Console.ReadLine().Split(), long.Parse);
        }
        public double[] ReadSplit_Double()
        {
            return ConvertAll(Console.ReadLine().Split(), double.Parse);
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public void Swap<T>(ref T a, ref T b)
        {
            T keep = a;
            a = b;
            b = keep;
        }

        static public void Display<T>(T[,] array2d, int n, int m)
        {
            for (var i = 0; i < n; i++)
            {
                for (var j = 0; j < m; j++)
                {
                    Console.Write($"{array2d[i, j]} ");
                }
                Console.WriteLine();
            }
        }

        static public long LPow(int a, int b)
        {
            return (long)Pow(a, b);
        }
    }
    static public class CalcI
    {
        public static int Gcd(int a, int b)
        {
            if (a * b == 0) { return Max(a, b); }
            return a % b == 0 ? b : Gcd(b, a % b);
        }
        public static int Lcm(int a, int b)
        {
            int g = Gcd(a, b);
            return a / g * b;
        }
        public static int Ceil(int n, int div)
        {
            return (n + div - 1) / div;
        }
    }
    static public class CalcL
    {
        public static long Gcd(long a, long b)
        {
            if (a * b == 0) { return Max(a, b); }
            return a % b == 0 ? b : Gcd(b, a % b);
        }
        public static long Lcm(long a, long b)
        {
            long g = Gcd(a, b);
            return a / g * b;
        }
        public static long Ceil(long n, long div)
        {
            return (n + div - 1) / div;
        }
    }
    class Modulo
    {
        private int M;
        private readonly long[] m_facs;
        public long Mul(long a, long b)
        {
            return ((a * b) % M);
        }
        public Modulo(long n, int m)
        {
            M = m;
            m_facs = new long[n + 1];
            m_facs[0] = 1;
            for (long i = 1; i <= n; ++i)
            {
                m_facs[i] = Mul(m_facs[i - 1], i);
            }
        }
        public long Fac(long n)
        {
            return m_facs[n];
        }
        public long Pow(long a, long m)
        {
            switch (m)
            {
                case 0:
                    return 1L;
                case 1:
                    return a;
                default:
                    long p1 = Pow(a, m / 2);
                    long p2 = Mul(p1, p1);
                    return ((m % 2) == 0) ? p2 : Mul(p2, a);
            }
        }
        public long Div(long a, long b)
        {
            return Mul(a, Pow(b, M - 2));
        }
        public long Ncr(long n, long r)
        {
            if (n < r) { return 0; }
            if (n == r) { return 1; }
            long res = Fac(n);
            res = Div(res, Fac(r));
            res = Div(res, Fac(n - r));
            return res;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;

class Solver
{
    public void Solve(Scanner sc)
    {
        int N, M;
        sc.Make(out N, out M);
        if (N > M + 1) Fail(0);
        if (N == 2) Fail(0);
        ModInt.Build(M + 1);
        ModInt res = 0;

        for(int i = 0; i < N - 2; i++)
        {
            res += ModInt.Comb(N - 3, i);
        }
        res *= ModInt.Comb(M, N - 1);
        WriteLine(res*(N-2));
    }
}

public struct ModInt
{
    //public const long MOD = (int)1e9 + 7;
    public const long MOD = 998244353;
    public long Value { get; set; }
    public ModInt(long n = 0) { Value = n; }
    private static ModInt[] fac;//階乗
    private static ModInt[] inv;//逆数
    private static ModInt[] facinv;//1/(i!)
    public override string ToString() => Value.ToString();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator +(ModInt l, ModInt r)
    {
        l.Value += r.Value;
        if (l.Value >= MOD) l.Value -= MOD;
        return l;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator -(ModInt l, ModInt r)
    {
        l.Value -= r.Value;
        if (l.Value < 0) l.Value += MOD;
        return l;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator *(ModInt l, ModInt r) => new ModInt(l.Value * r.Value % MOD);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator /(ModInt l, ModInt r) => l * Pow(r, MOD - 2);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator long(ModInt l) => l.Value;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator ModInt(long n)
    {
        n %= MOD; if (n < 0) n += MOD;
        return new ModInt(n);
    }

    public static ModInt Pow(ModInt m, long n)
    {
        if (n == 0) return 1;
        if (n % 2 == 0) return Pow(m * m, n >> 1);
        else return Pow(m * m, n >> 1) * m;
    }

    public static void Build(int n)
    {
        fac = new ModInt[n + 1];
        facinv = new ModInt[n + 1];
        inv = new ModInt[n + 1];
        inv[1] = 1;
        fac[0] = fac[1] = 1;
        facinv[0] = facinv[1] = 1;
        for (var i = 2; i <= n; i++)
        {
            fac[i] = fac[i - 1] * i;
            inv[i] = MOD - inv[MOD % i] * (MOD / i);
            facinv[i] = facinv[i - 1] * inv[i];
        }
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Fac(ModInt n) => fac[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Inv(ModInt n) => inv[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt FacInv(ModInt n) => facinv[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Comb(ModInt n, ModInt r)
    {
        if (n < r) return 0;
        if (n == r) return 1;
        var calc = fac[n];
        calc = calc * facinv[r];
        calc = calc * facinv[n - r];
        return calc;
    }
}
#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver().Solve(new Scanner());
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
    public static T[] Shuffle<T>(this IList<T> A) { T[] rt = A.ToArray(); Random rnd = new Random(); for (int i = rt.Length - 1; i >= 1; i--) swap(ref rt[i], ref rt[rnd.Next(i + 1)]); return rt; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}
public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
    //public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, v2); }
    //public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }
    //public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
    public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3;
    public Pair() : base() { }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString() => $"{base.ToString()} {v3.ToString()}";
    public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }
}
#endregion