import java.io.*;
import java.util.*;
public class icpc
{
    public static void main(String[] args) throws IOException
    {
        Reader in = new Reader();
        //BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        long l = in.nextLong();
        long r = in.nextLong();
        System.out.println(giveAns(r) - giveAns(l - 1));
    }
    public static long giveAns(long x)
    {
        int numOfDigits = Long.toString(x).length();
        long ans = 0L;
        for (int i=2;i<numOfDigits;i++)
            ans += 9L * (long)Math.pow(10, i - 2);
        if (numOfDigits > 1)
            ans += 9;
        if (numOfDigits == 1)
            ans += x;
        else
        {
            int firstDigit = Long.toString(x).charAt(0) - '0';
            int lastDigit = Long.toString(x).charAt(numOfDigits - 1) - '0';
            ans += (firstDigit - 1) * (long)Math.pow(10, numOfDigits - 2);
            String s = Long.toString(x);
            for (int j=1;j<numOfDigits - 1;j++)
            {
                long val = 1L;
                int digit = s.charAt(j) - '0';
                val *= (1L * digit * (long)Math.pow(10, numOfDigits - j - 2));
                ans += val;
            }
            if (firstDigit <= lastDigit)
                ans++;
        }
        return ans;
    }
}
class DSU
{
    int[] parent;
    int[] size;
    //Pass number of total nodes as parameter to the constructor
    DSU(int n)
    {
        this.parent = new int[n];
        this.size = new int[n];
        Arrays.fill(parent, -1);
    }

    public void makeSet(int v)
    {
        parent[v] = v;
        size[v] = 1;
    }

    public int findSet(int v)
    {
        if (v == parent[v]) return v;
        return parent[v] = findSet(parent[v]);
    }

    public void unionSets(int a, int b)
    {
        a = findSet(a);
        b = findSet(b);
        if (a != b)
        {
            if (size[a] < size[b])
            {
                int temp = a;
                a = b;
                b = temp;
            }
            parent[b] = a;
            size[a] += size[b];
        }
    }
}
class FastFourierTransform
{
    private void fft(double[] a, double[] b, boolean invert)
    {
        int count = a.length;
        for (int i = 1, j = 0; i < count; i++)
        {
            int bit = count >> 1;
            for (; j >= bit; bit >>= 1)
                j -= bit;
            j += bit;
            if (i < j)
            {
                double temp = a[i];
                a[i] = a[j];
                a[j] = temp;
                temp = b[i];
                b[i] = b[j];
                b[j] = temp;
            }
        }
        for (int len = 2; len <= count; len <<= 1)
        {
            int halfLen = len >> 1;
            double angle = 2 * Math.PI / len;
            if (invert)
                angle = -angle;
            double wLenA = Math.cos(angle);
            double wLenB = Math.sin(angle);
            for (int i = 0; i < count; i += len)
            {
                double wA = 1;
                double wB = 0;
                for (int j = 0; j < halfLen; j++)
                {
                    double uA = a[i + j];
                    double uB = b[i + j];
                    double vA = a[i + j + halfLen] * wA - b[i + j + halfLen] * wB;
                    double vB = a[i + j + halfLen] * wB + b[i + j + halfLen] * wA;
                    a[i + j] = uA + vA;
                    b[i + j] = uB + vB;
                    a[i + j + halfLen] = uA - vA;
                    b[i + j + halfLen] = uB - vB;
                    double nextWA = wA * wLenA - wB * wLenB;
                    wB = wA * wLenB + wB * wLenA;
                    wA = nextWA;
                }
            }
        }
        if (invert)
        {
            for (int i = 0; i < count; i++)
            {
                a[i] /= count;
                b[i] /= count;
            }
        }
    }

    public long[] multiply(long[] a, long[] b)
    {
        int resultSize = Integer.highestOneBit(Math.max(a.length, b.length) - 1) << 2;
        resultSize = Math.max(resultSize, 1);
        double[] aReal = new double[resultSize];
        double[] aImaginary = new double[resultSize];
        double[] bReal = new double[resultSize];
        double[] bImaginary = new double[resultSize];
        for (int i = 0; i < a.length; i++)
            aReal[i] = a[i];
        for (int i = 0; i < b.length; i++)
            bReal[i] = b[i];
        fft(aReal, aImaginary, false);
        fft(bReal, bImaginary, false);
        for (int i = 0; i < resultSize; i++)
        {
            double real = aReal[i] * bReal[i] - aImaginary[i] * bImaginary[i];
            aImaginary[i] = aImaginary[i] * bReal[i] + bImaginary[i] * aReal[i];
            aReal[i] = real;
        }
        fft(aReal, aImaginary, true);
        long[] result = new long[resultSize];
        for (int i = 0; i < resultSize; i++)
            result[i] = Math.round(aReal[i]);
        return result;
    }
}
class NumberTheory
{
    public boolean isPrime(long n)
    {
        if(n < 2)
            return false;
        for(long x = 2;x * x <= n;x++)
        {
            if(n % x == 0)
                return false;
        }
        return true;
    }
    public ArrayList<Long> primeFactorisation(long n)
    {
        ArrayList<Long> f = new ArrayList<>();
        for(long x=2;x * x <= n;x++)
        {
            while(n % x == 0)
            {
                f.add(x);
                n /= x;
            }
        }
        if(n > 1)
            f.add(n);
        return f;
    }
    public int[] sieveOfEratosthenes(int n)
    {
        //Returns an array with the smallest prime factor for each number and primes marked as 0
        int[] sieve = new int[n + 1];
        for(int x=2;x * x <= n;x++)
        {
            if(sieve[x] != 0)
                continue;
            for(int u=x*x;u<=n;u+=x)
            {
                if(sieve[u] == 0)
                {
                    sieve[u] = x;
                }
            }
        }
        return sieve;
    }
    public long gcd(long a, long b)
    {
        if(b == 0)
            return a;
        return gcd(b, a % b);
    }
    public long phi(long n)
    {
        double result = n;

        for(long p=2;p*p<=n;p++)
        {
            if(n % p == 0)
            {
                while (n % p == 0)
                    n /= p;
                result *= (1.0 - (1.0 / (double)p));
            }
        }
        if(n > 1)
            result *= (1.0 - (1.0 / (double)n));
        return (long)result;
    }
    public Name extendedEuclid(long a, long b)
    {
        if(b == 0)
            return new Name(a, 1, 0);
        Name n1 = extendedEuclid(b, a % b);
        Name n2 = new Name(n1.d, n1.y, n1.x - (long)Math.floor((double)a / b) * n1.y);
        return n2;
    }
    public long modularExponentiation(long a, long b, long n)
    {
        long d = 1L;
        String bString = Long.toBinaryString(b);
        for(int i=0;i<bString.length();i++)
        {
            d = (d * d) % n;
            if(bString.charAt(i) == '1')
                d = (d * a) % n;
        }
        return d;
    }
}
class Name
{
    long d;
    long x;
    long y;

    public Name(long d, long x, long y)
    {
        this.d = d;
        this.x = x;
        this.y = y;
    }
}
class SuffixArray
{
    int ALPHABET_SZ = 256, N;
    int[] T, lcp, sa, sa2, rank, tmp, c;

    public SuffixArray(String str)
    {
        this(toIntArray(str));
    }

    private static int[] toIntArray(String s)
    {
        int[] text = new int[s.length()];
        for (int i = 0; i < s.length(); i++) text[i] = s.charAt(i);
        return text;
    }

    public SuffixArray(int[] text)
    {
        T = text;
        N = text.length;
        sa = new int[N];
        sa2 = new int[N];
        rank = new int[N];
        c = new int[Math.max(ALPHABET_SZ, N)];
        construct();
        kasai();
    }

    private void construct()
    {
        int i, p, r;
        for (i = 0; i < N; ++i) c[rank[i] = T[i]]++;
        for (i = 1; i < ALPHABET_SZ; ++i) c[i] += c[i - 1];
        for (i = N - 1; i >= 0; --i) sa[--c[T[i]]] = i;
        for (p = 1; p < N; p <<= 1)
        {
            for (r = 0, i = N - p; i < N; ++i) sa2[r++] = i;
            for (i = 0; i < N; ++i) if (sa[i] >= p) sa2[r++] = sa[i] - p;
            Arrays.fill(c, 0, ALPHABET_SZ, 0);
            for (i = 0; i < N; ++i) c[rank[i]]++;
            for (i = 1; i < ALPHABET_SZ; ++i) c[i] += c[i - 1];
            for (i = N - 1; i >= 0; --i) sa[--c[rank[sa2[i]]]] = sa2[i];
            for (sa2[sa[0]] = r = 0, i = 1; i < N; ++i)
            {
                if (!(rank[sa[i - 1]] == rank[sa[i]]
                        && sa[i - 1] + p < N
                        && sa[i] + p < N
                        && rank[sa[i - 1] + p] == rank[sa[i] + p])) r++;
                sa2[sa[i]] = r;
            }
            tmp = rank;
            rank = sa2;
            sa2 = tmp;
            if (r == N - 1) break;
            ALPHABET_SZ = r + 1;
        }
    }

    private void kasai()
    {
        lcp = new int[N];
        int[] inv = new int[N];
        for (int i = 0; i < N; i++) inv[sa[i]] = i;
        for (int i = 0, len = 0; i < N; i++)
        {
            if (inv[i] > 0)
            {
                int k = sa[inv[i] - 1];
                while ((i + len < N) && (k + len < N) && T[i + len] == T[k + len]) len++;
                lcp[inv[i] - 1] = len;
                if (len > 0) len--;
            }
        }
    }
}
class ZAlgorithm
{
    public int[] calculateZ(char input[])
    {
        int Z[] = new int[input.length];
        int left = 0;
        int right = 0;
        for(int k = 1; k < input.length; k++) {
            if(k > right) {
                left = right = k;
                while(right < input.length && input[right] == input[right - left]) {
                    right++;
                }
                Z[k] = right - left;
                right--;
            } else {
                //we are operating inside box
                int k1 = k - left;
                //if value does not stretches till right bound then just copy it.
                if(Z[k1] < right - k + 1) {
                    Z[k] = Z[k1];
                } else { //otherwise try to see if there are more matches.
                    left = k;
                    while(right < input.length && input[right] == input[right - left]) {
                        right++;
                    }
                    Z[k] = right - left;
                    right--;
                }
            }
        }
        return Z;
    }
    public ArrayList<Integer> matchPattern(char text[], char pattern[])
    {
        char newString[] = new char[text.length + pattern.length + 1];
        int i = 0;
        for(char ch : pattern) {
            newString[i] = ch;
            i++;
        }
        newString[i] = '$';
        i++;
        for(char ch : text) {
            newString[i] = ch;
            i++;
        }
        ArrayList<Integer> result = new ArrayList<>();
        int Z[] = calculateZ(newString);

        for(i = 0; i < Z.length ; i++) {
            if(Z[i] == pattern.length) {
                result.add(i - pattern.length - 1);
            }
        }
        return result;
    }
}
class KMPAlgorithm
{
    public int[] computeTemporalArray(char[] pattern)
    {
        int[] lps = new int[pattern.length];

        int index = 0;
        for(int i=1;i<pattern.length;)
        {
            if(pattern[i] == pattern[index])
            {
                lps[i] = index + 1;
                index++;
                i++;
            }
            else
            {
                if(index != 0)
                {
                    index = lps[index - 1];
                }
                else
                {
                    lps[i] = 0;
                    i++;
                }
            }
        }
        return lps;
    }

    public ArrayList<Integer> KMPMatcher(char[] text, char[] pattern)
    {
        int[] lps = computeTemporalArray(pattern);

        int j = 0;
        int i = 0;
        int n = text.length;
        int m = pattern.length;
        ArrayList<Integer> indices = new ArrayList<>();
        while(i < n)
        {
            if(pattern[j] == text[i])
            {
                i++;
                j++;
            }
            if(j == m)
            {
                indices.add(i - j);
                j = lps[j - 1];
            }
            else if(i < n && pattern[j] != text[i])
            {
                if(j != 0)
                    j = lps[j - 1];
                else
                    i = i + 1;
            }
        }
        return indices;
    }
}
class Hashing
{
    public long[] computePowers(long p, int n, long m)
    {
        long[] powers = new long[n];
        powers[0] = 1;
        for(int i=1;i<n;i++)
        {
            powers[i] = (powers[i - 1] * p) % m;
        }
        return powers;
    }
    public long computeHash(String s)
    {
        long p = 31;
        long m = 1_000_000_009;
        long hashValue = 0L;
        long[] powers = computePowers(p, s.length(), m);
        for(int i=0;i<s.length();i++)
        {
            char ch = s.charAt(i);
            hashValue = (hashValue + (ch - 'a' + 1) * powers[i]) % m;
        }
        return hashValue;
    }
}
class BasicFunctions
{
    public long min(long[] A)
    {
        long min = Long.MAX_VALUE;
        for(int i=0;i<A.length;i++)
        {
            min = Math.min(min, A[i]);
        }
        return min;
    }
    public long max(long[] A)
    {
        long max = Long.MAX_VALUE;
        for(int i=0;i<A.length;i++)
        {
            max = Math.max(max, A[i]);
        }
        return max;
    }
}
class MergeSortInt
{
    // Merges two subarrays of arr[].
    // First subarray is arr[l..m]
    // Second subarray is arr[m+1..r]
    void merge(int arr[], int l, int m, int r) {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        int L[] = new int[n1];
        int R[] = new int[n2];

        /*Copy data to temp arrays*/
        for (int i = 0; i < n1; ++i)
            L[i] = arr[l + i];
        for (int j = 0; j < n2; ++j)
            R[j] = arr[m + 1 + j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2) {
            if (L[i] <= R[j]) {
                arr[k] = L[i];
                i++;
            } else {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1) {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2) {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    // Main function that sorts arr[l..r] using
    // merge()
    void sort(int arr[], int l, int r) {
        if (l < r) {
            // Find the middle point
            int m = (l + r) / 2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr, m + 1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }

}
class MergeSortLong
{
    // Merges two subarrays of arr[].
    // First subarray is arr[l..m]
    // Second subarray is arr[m+1..r]
    void merge(long arr[], int l, int m, int r) {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        long L[] = new long[n1];
        long R[] = new long[n2];

        /*Copy data to temp arrays*/
        for (int i = 0; i < n1; ++i)
            L[i] = arr[l + i];
        for (int j = 0; j < n2; ++j)
            R[j] = arr[m + 1 + j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2) {
            if (L[i] <= R[j]) {
                arr[k] = L[i];
                i++;
            } else {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1) {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2) {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    // Main function that sorts arr[l..r] using
    // merge()
    void sort(long arr[], int l, int r) {
        if (l < r) {
            // Find the middle point
            int m = (l + r) / 2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr, m + 1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }
}
class Node
{

    int x;
    int y;

    public Node(int x, int y)
    {
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object ob)
    {
        if(ob == null)
            return false;
        if(!(ob instanceof Node))
            return false;
        if(ob == this)
            return true;
        Node obj = (Node)ob;
        if(this.x == obj.x && this.y == obj.y)
            return true;
        return false;
    }

    @Override
    public int hashCode()
    {
        return (int)this.x;
    }
}
class Reader
{
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader()
    {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException
    {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException
    {
        byte[] buf = new byte[64]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1)
        {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do
        {
            ret = ret * 10 + c - '0';
        }  while ((c = read()) >= '0' && c <= '9');

        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException
    {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException
    {
        if (din == null)
            return;
        din.close();
    }
}
class FenwickTree
{
    public void update(long[] fenwickTree,long delta,int index)
    {
        index += 1;
        while(index < fenwickTree.length)
        {
            fenwickTree[index] += delta;
            index = index + (index & (-index));
        }
    }
    public long prefixSum(long[] fenwickTree,int index)
    {
        long sum = 0L;
        index += 1;
        while(index > 0)
        {
            sum += fenwickTree[index];
            index -= (index & (-index));
        }
        return sum;
    }
}
class SegmentTree
{
    public int nextPowerOfTwo(int num)
    {
        if(num == 0)
            return 1;
        if(num > 0 && (num & (num - 1)) == 0)
            return num;
        while((num &(num - 1)) > 0)
        {
            num = num & (num - 1);
        }
        return num << 1;
    }
    public int[] createSegmentTree(int[] input)
    {
        int np2 = nextPowerOfTwo(input.length);
        int[] segmentTree = new int[np2 * 2 - 1];

        for(int i=0;i<segmentTree.length;i++)
            segmentTree[i] = Integer.MIN_VALUE;

        constructSegmentTree(segmentTree,input,0,input.length-1,0);
        return segmentTree;

    }
    private void constructSegmentTree(int[] segmentTree,int[] input,int low,int high,int pos)
    {
        if(low == high)
        {
            segmentTree[pos] = input[low];
            return;
        }
        int mid = (low + high)/ 2;
        constructSegmentTree(segmentTree,input,low,mid,2*pos + 1);
        constructSegmentTree(segmentTree,input,mid+1,high,2*pos + 2);
        segmentTree[pos] = Math.max(segmentTree[2*pos + 1],segmentTree[2*pos + 2]);
    }
    public int rangeMinimumQuery(int []segmentTree,int qlow,int qhigh,int len)
    {
        return rangeMinimumQuery(segmentTree,0,len-1,qlow,qhigh,0);
    }
    private int rangeMinimumQuery(int segmentTree[],int low,int high,int qlow,int qhigh,int pos)
    {
        if(qlow <= low && qhigh >= high){
            return segmentTree[pos];
        }
        if(qlow > high || qhigh < low){
            return Integer.MIN_VALUE;
        }
        int mid = (low+high)/2;
        return Math.max(rangeMinimumQuery(segmentTree, low, mid, qlow, qhigh, 2 * pos + 1),
                rangeMinimumQuery(segmentTree, mid + 1, high, qlow, qhigh, 2 * pos + 2));
    }
}
class Trie
{

    private class TrieNode
    {
        Map<Character, TrieNode> children;
        boolean endOfWord;
        public TrieNode()
        {
            children = new HashMap<>();
            endOfWord = false;
        }
    }

    private final TrieNode root;
    public Trie()
    {
        root = new TrieNode();
    }

    public void insert(String word)
    {
        TrieNode current = root;
        for (int i = 0; i < word.length(); i++)
        {
            char ch = word.charAt(i);
            TrieNode node = current.children.get(ch);
            if (node == null)
            {
                node = new TrieNode();
                current.children.put(ch, node);
            }
            current = node;
        }
        current.endOfWord = true;
    }

    public boolean search(String word)
    {
        TrieNode current = root;
        for (int i = 0; i < word.length(); i++)
        {
            char ch = word.charAt(i);
            TrieNode node = current.children.get(ch);
            if (node == null)
            {
                return false;
            }
            current = node;
        }
        return current.endOfWord;
    }

    public void delete(String word)
    {
        delete(root, word, 0);
    }

    private boolean delete(TrieNode current, String word, int index)
    {
        if (index == word.length())
        {
            if (!current.endOfWord)
            {
                return false;
            }
            current.endOfWord = false;
            return current.children.size() == 0;
        }
        char ch = word.charAt(index);
        TrieNode node = current.children.get(ch);
        if (node == null)
        {
            return false;
        }
        boolean shouldDeleteCurrentNode = delete(node, word, index + 1);

        if (shouldDeleteCurrentNode)
        {
            current.children.remove(ch);
            return current.children.size() == 0;
        }
        return false;
    }
}
class SegmentTreeLazy
{
    public int nextPowerOfTwo(int num)
    {
        if(num == 0)
            return 1;
        if(num > 0 && (num & (num - 1)) == 0)
            return num;
        while((num &(num - 1)) > 0)
        {
            num = num & (num - 1);
        }
        return num << 1;
    }

    public int[] createSegmentTree(int input[])
    {
        int nextPowOfTwo = nextPowerOfTwo(input.length);
        int segmentTree[] = new int[nextPowOfTwo*2 -1];

        for(int i=0; i < segmentTree.length; i++){
            segmentTree[i] = Integer.MAX_VALUE;
        }
        constructMinSegmentTree(segmentTree, input, 0, input.length - 1, 0);
        return segmentTree;
    }

    private void constructMinSegmentTree(int segmentTree[], int input[], int low, int high,int pos)
    {
        if(low == high)
        {
            segmentTree[pos] = input[low];
            return;
        }
        int mid = (low + high)/2;
        constructMinSegmentTree(segmentTree, input, low, mid, 2 * pos + 1);
        constructMinSegmentTree(segmentTree, input, mid + 1, high, 2 * pos + 2);
        segmentTree[pos] = Math.min(segmentTree[2*pos+1], segmentTree[2*pos+2]);
    }

    public void updateSegmentTreeRangeLazy(int input[], int segmentTree[], int lazy[], int startRange, int endRange, int delta)
    {
        updateSegmentTreeRangeLazy(segmentTree, lazy, startRange, endRange, delta, 0, input.length - 1, 0);
    }

    private void updateSegmentTreeRangeLazy(int segmentTree[], int lazy[], int startRange, int endRange, int delta, int low, int high, int pos)
    {
        if(low > high)
        {
            return;
        }
        if (lazy[pos] != 0)
        {
            segmentTree[pos] += lazy[pos];
            if (low != high)
            {
                lazy[2 * pos + 1] += lazy[pos];
                lazy[2 * pos + 2] += lazy[pos];
            }
            lazy[pos] = 0;
        }

        if(startRange > high || endRange < low)
        {
            return;
        }

        if(startRange <= low && endRange >= high)
        {
            segmentTree[pos] += delta;
            if(low != high) {
                lazy[2*pos + 1] += delta;
                lazy[2*pos + 2] += delta;
            }
            return;
        }

        int mid = (low + high)/2;
        updateSegmentTreeRangeLazy(segmentTree, lazy, startRange, endRange, delta, low, mid, 2*pos+1);
        updateSegmentTreeRangeLazy(segmentTree, lazy, startRange, endRange, delta, mid+1, high, 2*pos+2);
        segmentTree[pos] = Math.min(segmentTree[2*pos + 1], segmentTree[2*pos + 2]);
    }

    public int rangeMinimumQueryLazy(int segmentTree[], int lazy[], int qlow, int qhigh, int len)
    {
        return rangeMinimumQueryLazy(segmentTree, lazy, qlow, qhigh, 0, len - 1, 0);
    }

    private int rangeMinimumQueryLazy(int segmentTree[], int lazy[], int qlow, int qhigh, int low, int high, int pos)
    {
        if(low > high)
        {
            return Integer.MAX_VALUE;
        }
        if (lazy[pos] != 0)
        {
            segmentTree[pos] += lazy[pos];
            if (low != high)
            {
                lazy[2 * pos + 1] += lazy[pos];
                lazy[2 * pos + 2] += lazy[pos];
            }
            lazy[pos] = 0;
        }

        if(qlow > high || qhigh < low)
        {
            return Integer.MAX_VALUE;
        }

        if(qlow <= low && qhigh >= high)
        {
            return segmentTree[pos];
        }

        int mid = (low+high)/2;
        return Math.min(rangeMinimumQueryLazy(segmentTree, lazy, qlow, qhigh, low, mid, 2 * pos + 1), rangeMinimumQueryLazy(segmentTree, lazy,  qlow, qhigh, mid + 1, high, 2 * pos + 2));
    }
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nl();
            long[] dp = new long[100000];
            dp[0] = 1;
            dp[1] = 2;
            for (int i = 1; ; ++i) {
                dp[i + 1] = dp[i] + dp[i - 1];
                if (dp[i + 1] > n) {
                    out.println(i);
                    return;
                }
            }
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
        }

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

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

    }
}


import java.util.Scanner;

public class cake {

	public static void main(String[] args) {
		Scanner in = new Scanner (System.in);
		int n = in.nextInt();
		int t = in.nextInt();
		int k = in.nextInt();
		int d = in.nextInt();
		int time1 = (d/t+1)*k;
		n = n - time1;
		if(n>0) {
			System.out.println("yes");
		}else {
			System.out.println("no");
		}

	}

}


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

public class Main
{
   public static void main(String[] args) throws IOException
   {
      new Main().run();
   }

   StreamTokenizer in;
   PrintWriter out;

   int nextInt() throws IOException
   {
      in.nextToken();
      return (int)in.nval;
   }

   void run() throws IOException
   {
      in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
      out = new PrintWriter(new OutputStreamWriter(System.out));
      solve();
      out.flush();
   }

   void solve() throws IOException
   {
     int n=6;
     int mas[]= new int[n];
     for (int i=0; i<n; i++){
     mas[i]=nextInt();
     }

     if ((mas[1]==0)&&(mas[0]==0)&&(mas[2]==0)&&(mas[3]==0)&&(mas[4]==0)&&(mas[5]==0)){
     out.print("Hermione");
     return;
     }

     if (mas[3]==0){out.print("Hermione");  return; }
     if (mas[2]==0){out.print("Ron");  return; }
     if (mas[1]==0){out.print("Hermione");  return; }
     if (mas[0]==0){out.print("Ron");  return; }
     if (mas[5]==0){out.print("Hermione");  return; }
     if (mas[4]==0){out.print("Ron");  return; }

     if ((mas[0]!=0)&&(mas[1]!=0)&&(mas[2]!=0)&&(mas[3]!=0)&&(mas[4]!=0)&&(mas[5]!=0)){
     if (mas[0]*mas[2]*mas[4]>=mas[1]*mas[3]*mas[5]){
     out.print("Hermione");
     }
     else{out.print("Ron");}
     }
     }
}


import java.io.*;
import java.util.*;
public class Solution {

	public static void print(int n)
	{
		if(n == 1)
			System.out.println('A');
		else if(n == 2)
			System.out.println('B');
		else if(n == 3)
			System.out.println('C');
		else
			System.out.println('D');
	}
	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		String A, B, C, D;
		InputStreamReader reader = new InputStreamReader(System.in);
		BufferedReader input = new BufferedReader(reader);
		A = input.readLine();
		B = input.readLine();
		C = input.readLine();
		D = input.readLine();
		int a[] = new int[4];
		a[0] = A.length() - 2;
		a[1] = B.length() - 2;
		a[2] = C.length() - 2;
		a[3] = D.length() - 2;
		int temp;
		for(int i = 0; i < 4; i++)
			for(int j = i; j < 4; j++)
				if(a[i] > a[j])
				{
					temp = a[i];
					a[i] = a[j];
					a[j] = temp;
				}
//		for(int i = 0; i < 4; i++)
//			System.out.print(a[i]);
		if((a[0]*2 <= a[1] || a[2]*2 <= a[3]) && !(2*a[0] <= a[1] && 2*a[2] <= a[3]))
		{
			if(a[0]*2 > a[1])
				a[0] = a[3];
			if(A.length() - 2 == a[0])
				print(1);
			else if(B.length()-2 == a[0])
				print(2);
			else if(C.length() - 2== a[0])
				print(3);
			else
				print(4);
			return;
		}
		print(3);

	}

}


import java.util.Scanner;

public class Snowball_1099A {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int w = input.nextInt(), h = input.nextInt();
		int u1 = input.nextInt(), d1 = input.nextInt();
		int u2 = input.nextInt(), d2 = input.nextInt();
		for (int i = h; i > 0; i--) {
			w += i;
			if (i == d1)
				w -= u1;
			else if (i == d2)
				w -= u2;
			if (w < 0)
				w = 0;
		}
		System.out.println(w);
		input.close();
	}
}


//package com.baba;

import java.util.Scanner;

public class Main {
    static char[] result = {'+', '-', '0', '?'};

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int x = s.nextInt();
        int y = s.nextInt();
        int z = s.nextInt();
        System.out.println(result[solve(x + z, y) == solve(x, y + z) ? solve(x, y) : 3]);
    }

    static int solve(int x, int y) {
        return x == y ? 2 : x < y ? 1 : 0;
    }
}


import java.util.*;
import java.io.*;
public class MainClass
{
    public static void main(String[] args) throws IOException
    {
        Reader in = new Reader();
        long a = in.nextLong();
        long b = in.nextLong();
        boolean ff = true;
        ArrayList<Long> B = new ArrayList<>();
        B.add(b);
        while (b > a)
        {
            if (b % 2 == 0L)
            {
                b /= 2L;
                if (b < a)
                {
                    ff = false;
                    break;
                }
                B.add(b);
            }
            else if (b % 10 == 1L)
            {
                b = (b - 1L) / 10L;
                if (b < a)
                {
                    ff = false;
                    break;
                }
                else
                {
                    B.add(b);
                }
            }
            else
            {
                ff = false;
                break;
            }
        }
        StringBuilder stringBuilder = new StringBuilder();
        if (ff)
        {
            Collections.reverse(B);
            stringBuilder.append("YES\n").append(B.size()).append("\n");
            for (long i: B)  stringBuilder.append(i).append(" ");
        }
        else
            stringBuilder.append("NO\n");
        System.out.println(stringBuilder);
    }
}
class Reader
{
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader()
    {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException
    {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException
    {
        byte[] buf = new byte[64]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1)
        {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do
        {
            ret = ret * 10 + c - '0';
        }  while ((c = read()) >= '0' && c <= '9');

        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException
    {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException
    {
        if (din == null)
            return;
        din.close();
    }
}


import java.util.Scanner;

/**
 * Created by aksinha on 2/1/2017.
 */
public class Multiplication {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int a1 = in.nextInt();
        int b1 = in.nextInt();
        int c1 = in.nextInt();

        if (a1 == a){
            System.out.println("YES");
        }
        else if (b1 == b){
            System.out.println("YES");
        }
        else if (c1 == c){
            System.out.println("YES");
        }
        else
            System.out.println("NO");
    }
}


import java.util.Scanner;

public class TheNewYearMeetingFriends {

    public static void main(String[] args) {
        Scanner kbd = new Scanner(System.in);
        int a = kbd.nextInt();
        int b = kbd.nextInt();
        int c = kbd.nextInt();
        int min = Math.min(a, Math.min(b,c));
        int max = Math.max(a,Math.max(b,c));
        System.out.println(max-min);
    }
}


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

public class LuckySubstring {

    public static void main(String[] args) throws NumberFormatException,
            IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String num = br.readLine().trim();
        int count4 = 0, count7 = 0;
        if (num.substring(0, 1).equals("0"))
            num = num.substring(1, num.length());
        for (int i = 0; i < num.length(); i++) {
            if (num.charAt(i) == '7')
                count7++;
            else if (num.charAt(i) == '4')
                count4++;
        }
        if (count4 == 0 && count7 == 0)
            System.out.println(-1);
        else if (count4 >= count7)
            System.out.println(4);
        else
            System.out.println(7);
    }

}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {

		Scanner kb = new Scanner(System.in);
		int rows = kb.nextInt();
		int columns = kb.nextInt();
		kb.nextLine();
		int[][] distances = new int[rows * columns][rows * columns];
		for (int i = 0; i < rows * columns; i++) {
			Arrays.fill(distances[i], 10000);
		}
		for (int i = 0; i < rows * columns; i++) {
			distances[i][i] = 0;
		}
		String rowLine = kb.nextLine();
		char[] rowLinesplit = rowLine.toCharArray();
		for (int i = 0; i < rows; i++) {
			if (rowLinesplit[i] == '<') {
				for (int j = columns - 1; j > 0; j --) {
					int from = i * columns + j;
					int to = i * columns + j - 1;
					distances[from][to] = 1;
				}
			} else if (rowLinesplit[i] == '>') {
				for (int j = 0; j < columns - 1; j++) {
					int from = i * columns + j;
					int to = i * columns + j + 1;
					distances[from][to] = 1;
				}
			}
		}
		String columnLine = kb.nextLine();
		char[] columnLineSplit = columnLine.toCharArray();
		for (int i = 0; i < columns; i++) {
			if (columnLineSplit[i] == 'v') {
				for (int j = 0; j < rows - 1; j++) {
					int from = j * columns + i;
					int to = (j + 1) * columns + i;
					distances[from][to] = 1;
				}
			} else if (columnLineSplit[i] == '^') {
				for (int j = rows - 1; j > 0; j--) {
					int from = j * columns + i;
					int to = (j - 1) * columns + i;
					distances[from][to] = 1;
				}
			}
		}

		for (int k = 0; k < rows * columns; k++) {
			for (int i = 0; i < rows * columns; i++) {
				for (int j = 0; j < rows * columns; j++) {
					distances[i][j] = Math.min(distances[i][j], distances[i][k] + distances[k][j]);
				}
			}
		}
		for (int i = 0; i < rows * columns; i++) {
			for (int j = 0; j < rows * columns; j++) {
				if (distances[i][j] == 10000) {
					System.out.println("NO");
					return;
				}
			}
		}
		System.out.println("YES");
	}

}


import java.math.BigDecimal;
import java.util.Scanner;
public class Test2 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String in =sc.nextLine();
		BigDecimal  x = new BigDecimal(in);
		//System.out.println(x);
		System.out.println(x.stripTrailingZeros().toPlainString());
	}
}


//package GeneralProblems;

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

public class PIERULES {
	static int [] elm;
	static int memo[][][];
	public static void dp(int idx, int turn) {
		if(idx==elm.length) {
			memo[idx][turn][turn]=0;
			memo[idx][turn][1-turn]=0;
			return;
		}
		if(memo[idx][turn][0]!=-1)
			return;
		dp(idx+1,turn);
		dp(idx+1,1-turn);
		//first case i leave it and give it to the other player
		int sc1 = memo[idx+1][turn][turn], sc2 = memo[idx+1][turn][1-turn]+elm[idx];
		int sc11 = memo[idx+1][1-turn][turn]+elm[idx], sc21 = memo[idx+1][1-turn][1-turn];
		if(sc1>sc11) {
			memo[idx][turn][turn]= sc1;
			memo[idx][turn][1-turn]=sc2;
		}else {
			memo[idx][turn][turn]= sc11;
			memo[idx][turn][1-turn]=sc21;
		}

		}
public static void main(String[] args) throws IOException{
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	int n = Integer.parseInt(in.readLine());
	elm = new int[n];
	StringTokenizer st= new StringTokenizer(in.readLine());
	for (int i = 0; i < elm.length; i++) {
		elm[i]=Integer.parseInt(st.nextToken());
	}
	memo =new int[n+1][2][2];
	for (int i = 0; i < memo.length; i++) {
		for (int j = 0; j < memo[0].length; j++) {
			Arrays.fill(memo[i][j],-1);
		}
	}
	dp(0,0);
	System.out.println(memo[0][0][1]+" "+memo[0][0][0]);

}
}


import java.util.Scanner;

public class ProblemA {

    /**
     * @param args
     */
    public static void main(String[] args) {
        ProblemA problem = new ProblemA();
        problem.solve();
    }

    private void solve() {
        Scanner sc = new Scanner(System.in);
        String s1 = sc.next();
        String s2 = sc.next();
        String s3 = sc.next();
        if (win(s1, s2, s3)) {
            System.out.println("F");
        } else if (win(s2, s1, s3)) {
            System.out.println("M");
        } else if (win(s3, s1, s2)) {
            System.out.println("S");
        } else {
            System.out.println("?");
        }
    }

    private boolean win(String s1, String s2, String s3) {
        if (!s2.equals(s3)) {
            return false;
        }
        if (s1.equals("rock") && s2.equals("scissors")) {
            return true;
        }
        if (s1.equals("scissors") && s2.equals("paper")) {
            return true;
        }
        if (s1.equals("paper") && s2.equals("rock")) {
            return true;
        }
        return false;
    }

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskB {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int k = in.nextInt();
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = i;
			}
			for (int i = 0; i < Math.min(k, n / 2); i++) {
				int t = a[i];
				a[i] = a[n - 1 - i];
				a[n - 1 - i] = t;
			}
			long res = inversions(a, 0, n);
			out.println(res);
		}

		static long inversions(int[] a, int low, int high) {
			if (high - low < 2)
				return 0;
			int mid = (low + high) >>> 1;
			long res = inversions(a, low, mid) + inversions(a, mid, high);
			int[] b = Arrays.copyOfRange(a, low, mid);
			for (int i = low, j = mid, k = 0; k < b.length; i++)
				if (j == high || b[k] <= a[j]) {
					a[i] = b[k++];
				} else {
					a[i] = a[j++];
					res += b.length - k;
				}
			return res;
		}

	}

	static class InputReader {
		final InputStream is;
		final byte[] buf = new byte[1024];
		int pos;
		int size;

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

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

		int read() {
			if (size == -1)
				throw new InputMismatchException();
			if (pos >= size) {
				pos = 0;
				try {
					size = is.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (size <= 0)
					return -1;
			}
			return buf[pos++] & 255;
		}

		static boolean isWhitespace(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

	}
}


import java.util.Scanner;

public class Test{

    public static void main(String[] args) {

        int []a = new int[5];
        int sum=0;
        Scanner in = new Scanner(System.in);

        for(int i =0; i <5; i++)
        {
            a[i] = in.nextInt();
            sum = sum +a[i];
        }

        if (sum%5!=0||sum==0)
            System.out.println("-1");
    else
            System.out.println(sum/5);

    }

}


import java.util.Scanner;

public class A
{
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        if (n % 2 == 1) System.out.println(0);
        else System.out.println((int) Math.pow(2, n / 2));
    }
}


// package PCS;

import java.util.Scanner;

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

        int c1 = reader.nextInt();
        int c2 = reader.nextInt();
        int c3 = reader.nextInt();
        int c4 = reader.nextInt();
        System.out.println(((c3 < 1 || c1 > 0) && c1 == c4) ? "1" : "0");
    }
}


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

public class R136B {
    public static void main (String[] args) throws java.lang.Exception {
        InputReader in = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);
        int x = in.nextInt(), ans = 0;
        for (int i = 1; i <= Math.sqrt(x); i++) {
            if (x % i == 0) {
                if (hasCommon(x, i))
                    ans++;
                if (x / i != i && hasCommon(x, x / i) )
                    ans++;
            }
        }
        w.println(ans);

        w.close();
    }
    static boolean hasCommon(int x, int y) {
        HashSet<Integer> hs = new HashSet<>();
        while (x > 0) {
            hs.add(x % 10);
            x /= 10;
        }
        while (y > 0) {
            if (hs.contains(y % 10))
                return true;
            y /= 10;
        }
        return false;
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

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

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

        public int peek() {
            if (numChars == -1)
                return -1;
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    return -1;
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar];
        }

        public void skip(int x) {
            while (x-- > 0)
                read();
        }

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

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

        public String nextString() {
            return next();
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        public String nextLine() {
            StringBuffer buf = new StringBuffer();
            int c = read();
            while (c != '\n' && c != -1) {
                if (c != '\r')
                    buf.appendCodePoint(c);
                c = read();
            }
            return buf.toString();
        }

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }
        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
        public boolean hasNext() {
            int value;
            while (isSpaceChar(value = peek()) && value != -1)
                read();
            return value != -1;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}


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

public class C
{
	String line;
	StringTokenizer inputParser;
	BufferedReader is;
	FileInputStream fstream;
	DataInputStream in;
	String FInput="";

	void openInput(String file)
	{

		if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin
		else
		{
			try{

			fstream = new FileInputStream(file);
			in = new DataInputStream(fstream);
			is = new BufferedReader(new InputStreamReader(in));
			}catch(Exception e)
			{
				System.err.println(e);
			}
		}

	}

	void readNextLine()
	{
		try {
			line = is.readLine();
			inputParser = new StringTokenizer(line, " ");
			//System.err.println("Input: " + line);
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	int NextInt()
	{
		String n = inputParser.nextToken();
		int val = Integer.parseInt(n);

		//System.out.println("I read this number: " + val);
		return val;
	}

	String NextString()
	{
		String n = inputParser.nextToken();
		return n;
	}

	void closeInput()
	{
		try {
			is.close();
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}

	}

	public void readFInput()
	{
		for(;;)
		{
			try
			{
				readNextLine();
				FInput+=line+" ";
			}
			catch(Exception e)
			{
				break;
			}
		}
		inputParser = new StringTokenizer(FInput, " ");
	}

	long NextLong()
    {
            String n = inputParser.nextToken();

            long val = Long.parseLong(n);

            return val;
    }

	public static void main(String [] argv)
	{
		String filePath=null;
		if(argv.length>0)filePath=argv[0];
		new C(filePath);
	}

	public C(String inputFile)
	{
		openInput(inputFile);

		readNextLine();
		int x1=NextInt();
		int y1=NextInt();
		int r1=NextInt();
		int R1=NextInt();
		readNextLine();
		int x2=NextInt();
		int y2=NextInt();
		int r2=NextInt();
		int R2=NextInt();

		int ret=0;
		double d=Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
		if(r1<=d-r2&&r1<=d-R2||(r1>=d+r2&&r1>=d+R2)||(r1+d<=r2&&r1+d<=R2))ret++;
		if(R1<=d-r2&&R1<=d-R2||(R1>=d+r2&&R1>=d+R2)||(R1+d<=r2&&R1+d<=R2))ret++;
		if(r2<=d-r1&&r2<=d-R1||(r2>=d+r1&&r2>=d+R1)||(r2+d<=r1&&r2+d<=R1))ret++;
		if(R2<=d-r1&&R2<=d-R1||(R2>=d+r1&&R2>=d+R1)||(R2+d<=r1&&R2+d<=R1))ret++;

		System.out.println(ret);
        closeInput();
	}

}


/**
 * check out my youtube channel sh0rkyboy
 * https://tinyurl.com/zdxe2y4z
 * I do screencasts, solutions, and other fun stuff in the future
 */

import java.util.*;
import java.io.*;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import static java.lang.Math.max;
public class EdA {
	static long[] mods = {1000000007, 998244353, 1000000009};
	static long mod = mods[1];
	public static MyScanner sc;
    public static PrintWriter out;
    static long[] fact;
    static long[] inv;
    static long[][] power;
	public static long inv(long n){
		return power(n, mod-2);
	}
	public static void fact(int n){
		fact = new long[n+1];
		fact[0] = 1;
		for(int j = 1;j<=n;j++){
			fact[j] = (fact[j-1]*(long)j)%mod;
		}
	}
	public static long binom(int n, int k){
		long prod = fact[n];
		prod*=inv(fact[n-k]);
		prod%=mod;
		prod*=inv(fact[k]);
		prod%=mod;
		return prod;
	}
	public static void main(String[] largewang) throws Exception{
		// TODO Auto-generated method stub
 		sc = new MyScanner();
 		out = new PrintWriter(System.out);
 			int n = sc.nextInt();
 			int x = sc.nextInt();
 			long[][] dp = new long[n+1][x+1];
 			long[][] binom = new long[501][501];

 			power = new long[501][501];
 			for(int j = 1;j<=500;j++){
 				for(int k = 0;k<=j;k++){
 					power[j][k] = power(j, k);
 				}
 			}
 			for(int j = 1;j<=x;j++)
 				dp[1][j] = j;
 			fact(500);
 			for(int j = 1;j<=500;j++){
 				for(int k = 0;k<=j;k++){
 					binom[j][k] = binom(j, k);
 				}
 			}
 			for(int j = 2;j<=n;j++){
 				for(int k = 1;k<=x;k++){
 					for(int l = 0;l<=j-1;l++){
 						if (k >= j-1){
 							long prod = dp[j-l][k-(j-1)]*power[j-1][l];
 							prod %= mod;
 							prod *= binom[j][l];
 							prod %= mod;
 							dp[j][k] += prod;
 							while (dp[j][k] >= mod)
 								dp[j][k] -= mod;
 						}
 					}
 				}
 			}
 			long ans = power(x, n) - dp[n][x];
 			ans %= mod;
 			ans += mod;
 			ans %= mod;
 			out.println(ans);

 		out.close();

 	}

	public static void sort(int[] array){
		ArrayList<Integer> copy = new ArrayList<>();
		for (int i : array)
			copy.add(i);
		Collections.sort(copy);
		for(int i = 0;i<array.length;i++)
			array[i] = copy.get(i);
	}
	static String[] readArrayString(int n){
		String[] array = new String[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.next();
		return array;
	}
	static int[] readArrayInt(int n){
    	int[] array = new int[n];
    	for(int j = 0;j<n;j++)
    		array[j] = sc.nextInt();
    	return array;
    }
	static int[] readArrayInt1(int n){
		int[] array = new int[n+1];
		for(int j = 1;j<=n;j++){
			array[j] = sc.nextInt();
		}
		return array;
	}
	static long[] readArrayLong(int n){
		long[] array = new long[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextLong();
		return array;
	}
	static double[] readArrayDouble(int n){
		double[] array = new double[n];
		for(int j =0 ;j<n;j++)
			array[j] = sc.nextDouble();
		return array;
	}
	static int minIndex(int[] array){
		int minValue = Integer.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(long[] array){
		long minValue = Long.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static int minIndex(double[] array){
		double minValue = Double.MAX_VALUE;
		int minIndex = -1;
		for(int j = 0;j<array.length;j++){
			if (array[j] < minValue){
				minValue = array[j];
				minIndex = j;
			}
		}
		return minIndex;
	}
	static long power(long x, long y){
		if (y == 0)
			return 1;
		if (y%2 == 1)
			return (x*power(x, y-1))%mod;
		return power((x*x)%mod, y/2)%mod;
	}
	static void verdict(boolean a){
        out.println(a ? "YES" : "NO");
    }
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}

//StringJoiner sj = new StringJoiner(" ");
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is


import java.util.Scanner;

public class EvenOddGame_959A {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        if(n%2==0){
            System.out.println("Mahmoud");
        }
        else{
            System.out.println("Ehab");
        }
    }
}


import java.io.*;
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.BufferedWriter;
import java.io.File;
import java.io.PrintWriter;
import java.util.Scanner;

public class A {
	public static void main(String[] args) throws IOException {
		BufferedInputStream inputStream = new BufferedInputStream(System.in);
		BufferedOutputStream outputStream = new BufferedOutputStream(System.out);
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);

		char bus[][] = new char[][] {
				"+------------------------+".toCharArray(),
				"|#.#.#.#.#.#.#.#.#.#.#.|D|)".toCharArray(),
				"|#.#.#.#.#.#.#.#.#.#.#.|.|".toCharArray(),
				"|#.......................|".toCharArray(),
				"|#.#.#.#.#.#.#.#.#.#.#.|.|)".toCharArray(),
				"+------------------------+".toCharArray()
		};
		int n = in.nextInt();
		int lim = Math.min(n,4);
		for (int i = 0; i < lim; i++) {
			bus[i+1][1] = 'O';
		}

		int rSeq[] = new int[]{1,2,4};
		int col = 3;
		for (int i = 4,r = 0; i < n; i++,r++) {
			bus[rSeq[r%3]][col] = 'O';
			if(r%3 == 2)
				col+=2;
		}

		for (int i = 0; i < bus.length; i++) {
			for (int j = 0; j < bus[i].length; j++) {
				out.append(bus[i][j]);
			}
//			if(i != bus.length -1)
				out.append("\n");
		}
		out.close();

	}
}


import java.io.*;
public class Chloeandthesequence {

	public static void main(String[] args) throws IOException{
			BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
			String [] l = b.readLine().split(" ");
			long x = Integer.parseInt(l[0]);
			long y =  Long.parseLong(l[1]);
			long s = 1;
			for(int i = 1 ; i < x;i++)
			 s = s*2+1;
			long m =1;
			long lo = 1;
			long hi = s;
			long target= x;
			//System.out.println(s);
			while(lo<hi){

				m = (lo+hi)/2;
				if(y<m){
					hi = m-1;
					target--;
				}else if(y>m){
					lo = m+1;
					target--;
				}else{
				 break;
				}
				//System.out.println(target+" "+y+" "+m);
			}
			System.out.println(target);

	}

}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        long n = in.nextInt();
        if (n == 1) {
            out.println(1);
        } else if (n == 2) {
            out.println(2);
        } else {
            long ans = 0;
            int lower = (int) (n <= 100 ? 1 : n - 100);
            for (int i = lower; i <= n; i++) {
                for (int j = lower; j <= n; j++) {
                    for (int k = lower; k <= n; k++) {
                        ans = Math.max(lcm(lcm(i, j), k), ans);
                    }
                }
            }
            out.println(ans);
        }
    }

    public long gcd(long x, long y) {
        return y == 0 ? x : gcd(y, x % y);
    }

    public long lcm(long x, long y) {
        return x * y / gcd(x, y);
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

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

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

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

}


import java.util.*;
import java.io.*;
import java.math.*;
public class main {
	InputStream is;
	PrintWriter out;
	static long mod=pow(10,9)+7;
	int dx[]= {0,0,1,-1},dy[]={+1,-1,0,0};
	void solve()
	{
		long l=ni();
		long r=ni();
		long x=ni();
		long y=ni();
		if(y%x!=0) {
			out.print(0);
			return;
		}
		long filter=y/x;
		long count=0;
		for(int i=1;i*i<=filter;i++)
		{
			if(filter%i==0) {
				if((filter/i)!=i) {
					long gcd=gcd(filter/i,i);
					if(gcd!=1)
						continue;
					if(i*x>=l&&i*x<=r&&(filter/i)*x>=l&&(filter/i)*x<=r)
						count+=2;
				}
				else if(i==1&&i*x>=l&&i*x<=r)
					count++;
			}
		}
		out.println(count);
	}
	int bsdown(ArrayList<Integer> al,int l) {
		int low=0,high=al.size()-1,ans=-1;
		while(low<=high) {
			int mid=low+(high-low)/2;
			if(al.get(mid)<=l) {
				low=mid+1;
				ans=mid;
			}else
				high=mid-1;
		}
		return ans;
	}
	ArrayList<Integer>al [];
	void take(int n,int m)
	{
		al=new ArrayList[n];
		for(int i=0;i<n;i++)
			al[i]=new ArrayList<Integer>();
		for(int i=0;i<m;i++)
		{
			int x=ni()-1;
			int y=ni()-1;
			al[x].add(y);
			al[y].add(x);

		}
	}
	int arr[][];
	int small[];
	void pre(int n)
	{
		small=new int[n+1];
		for(int i=2;i*i<=n;i++)
		{
			for(int j=i;j*i<=n;j++)
			{
				if(small[i*j]==0)
					small[i*j]=i;
			}
		}
		for(int i=0;i<=n;i++)
		{
			if(small[i]==0)
				small[i]=i;
		}
	}
	public static int count(long x)
	{
		int num=0;
		while(x!=0)
		{
			x=x&(x-1);
			num++;
		}
		return num;
	}
	static long d, x, y;
	void extendedEuclid(long A, long B) {
	    if(B == 0) {
	        d = A;
	        x = 1;
	        y = 0;
	    }
	    else {
	        extendedEuclid(B, A%B);
	        long temp = x;
	        x = y;
	        y = temp - (A/B)*y;
	    }
	}
	long modInverse(long A,long M) //A and M are coprime
	{
	    extendedEuclid(A,M);
	    return (x%M+M)%M;    //x may be negative
	}
	public static void mergeSort(int[] arr, int l ,int r){
		if((r-l)>=1){
			int mid = (l+r)/2;
			mergeSort(arr,l,mid);
			mergeSort(arr,mid+1,r);
			merge(arr,l,r,mid);
		}
	}
	public static void merge(int arr[], int l, int r, int mid){
		int n1 = (mid-l+1), n2 = (r-mid);
		int left[] = new int[n1];
		int right[] = new int[n2];
		for(int i =0 ;i<n1;i++) left[i] = arr[l+i];
		for(int i =0 ;i<n2;i++) right[i] = arr[mid+1+i];
		int i =0, j =0, k = l;
		while(i<n1 && j<n2){
			if(left[i]>right[j]){
				arr[k++] = right[j++];
			}
			else{
				arr[k++] = left[i++];
			}
		}
		while(i<n1) arr[k++] = left[i++];
		while(j<n2) arr[k++] = right[j++];
	}
	public static void mergeSort(long[] arr, int l ,int r){
		if((r-l)>=1){
			int mid = (l+r)/2;
			mergeSort(arr,l,mid);
			mergeSort(arr,mid+1,r);
			merge(arr,l,r,mid);
		}
	}
	public static void merge(long arr[], int l, int r, int mid){
		int n1 = (mid-l+1), n2 = (r-mid);
		long left[] = new long[n1];
		long right[] = new long[n2];
		for(int i =0 ;i<n1;i++) left[i] = arr[l+i];
		for(int i =0 ;i<n2;i++) right[i] = arr[mid+1+i];
		int i =0, j =0, k = l;
		while(i<n1 && j<n2){
			if(left[i]>right[j]){
				arr[k++] = right[j++];
			}
			else{
				arr[k++] = left[i++];
			}
		}
		while(i<n1) arr[k++] = left[i++];
		while(j<n2) arr[k++] = right[j++];
	}
	 static class Pair implements Comparable<Pair>{

	      long x;
	      long y,k;
	      int i,h;
	      String s;
		Pair (long x,long y,int i){
			this.x=x;
			this.y=y;
			this.i=i;
		}

		public int compareTo(Pair o) {
			if(this.x!=o.x)
				return Long.compare(this.x,o.x);
			return Long.compare(this.y,o.y);
		}
		public boolean equals(Object o) {
			if (o instanceof Pair) {
				Pair p = (Pair)o;
				return p.x == x && p.y == y;
			}
			return false;
		}
		public int hashCode() {
			return new Long(x).hashCode()*31 + new Long(y).hashCode() ;
		}

	        @Override
	        public String toString() {
	            return  "("+x + " " + y +" "+k+" "+i+" )";
	        }

	    }

	    public static boolean isPal(String s){
	        for(int i=0, j=s.length()-1;i<=j;i++,j--){
	                if(s.charAt(i)!=s.charAt(j)) return false;
	        }
	        return true;
	    }
	    public static String rev(String s){
			StringBuilder sb=new StringBuilder(s);
			sb.reverse();
			return sb.toString();
	    }

	    public static long gcd(long x,long y){
		if(x%y==0)
			return y;
		else
			return gcd(y,x%y);
	    }

	    public static int gcd(int x,int y){
	    	if(y==0)
	    		return x;
	    	return gcd(y,x%y);
	    }

	    public static long gcdExtended(long a,long b,long[] x){

	        if(a==0){
	            x[0]=0;
	            x[1]=1;
	            return b;
	        }
	        long[] y=new long[2];
	        long gcd=gcdExtended(b%a, a, y);

	        x[0]=y[1]-(b/a)*y[0];
	        x[1]=y[0];

	        return gcd;
	    }

	    public static int abs(int a,int b){
		return (int)Math.abs(a-b);
	    }

	    public static long abs(long a,long b){
		return (long)Math.abs(a-b);
	    }

	    public static int max(int a,int b){
		if(a>b)
			return a;
		else
			return b;
	    }

	    public static int min(int a,int b){
		if(a>b)
			return b;
		else
			return a;
	    }

	    public static long max(long a,long b){
		if(a>b)
			return a;
		else
			return b;
	    }

	    public static long min(long a,long b){
		if(a>b)
			return b;
		else
			return a;
	    }

	    public static long pow(long n,long p,long m){
		 long  result = 1;
		  if(p==0)
		    return 1;
		if (p==1)
		    return n;
		while(p!=0)
		{
		    if(p%2==1)
		        result *= n;
		    if(result>=m)
		    result%=m;
		    p >>=1;
		    n*=n;
		    if(n>=m)
		    n%=m;
		}
		return result;
	    }

	    public static long pow(long n,long p){
		long  result = 1;
		  if(p==0)
		    return 1;
		if (p==1)
		    return n;
		while(p!=0)
		{
		    if(p%2==1)
		        result *= n;
		    p >>=1;
		    n*=n;
		}
		return result;
	    }
	    public static void debug(Object... o) {
			System.out.println(Arrays.deepToString(o));
		}
	    void run() throws Exception {
			is = System.in;
			out = new PrintWriter(System.out);
			solve();
			out.flush();
		}

	    public static void main(String[] args) throws Exception {
			new Thread(null, new Runnable() {
				public void run() {
					try {
						new main().run();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}, "1", 1 << 26).start();

		}
	    private byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		private int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b));
			return b;
		}

		private double nd() {
			return Double.parseDouble(ns());
		}

		private char nc() {
			return (char) skip();
		}

		private String ns() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		private char[] ns(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		private char[][] nm(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = ns(m);
			return map;
		}

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

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

		private int ni() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		private long nl() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

}


// @author Sanzhar
import java.awt.Point;
import java.io.*;
import java.util.*;

public class Template {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st;

    String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(in.readLine());
            } catch (Exception e) {
            }
        }
        return st.nextToken();
    }

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

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

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

    public void run() throws Exception {
        //in = new BufferedReader(new FileReader("input.txt"));
        //out = new PrintWriter(new FileWriter("output.txt"));
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.flush();
        out.close();
        in.close();
    }
    long mod = 1000000007;

    long binpow(long a, long x) {
        long res = 1;
        while (x > 0) {
            if (x % 2 == 1) {
                res *= a;
                res %= mod;
                x--;
            } else {
                a *= a;
                a %= mod;
                x /= 2;
            }
        }
        return res % mod;
    }

    public void solve() throws Exception {
        int[] m = {2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281,
            3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503, 132049, 216091, 756839, 859433, 1257787, 1398269, 2976221, 3021377, 6972593, 13466917, 20996011};
        int n = nextInt() - 1;
        int t = m[n] - 1;
        long ans = (binpow(2, (long) t) - 1 + mod) % mod;
        out.println(ans);
    }

    public static void main(String[] args) throws Exception {
        new Template().run();
    }
}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		long m=1000000007;

		long x=s.nextLong();
		long n=s.nextLong();

		boolean[] prime=new boolean[500001];

		seive(prime,500000);

		ArrayList<Long> list=new ArrayList<>();

		for(long i=2;i<=500000;i++)
		{
			if(prime[(int)i]&&x%i==0)
			{
				list.add(i);

				while(x%i==0)
				{
					x=x/i;
				}
			}
		}

		if(x!=1)
		list.add(x);

		//System.out.println(list);

		long ans=1;

		for(int i=0;i<list.size();i++)
		{
			long count=0;

			for(long j=list.get(i);j<=n;j=j*list.get(i))
			{
				count=count+(n/j);
				if(Long.MAX_VALUE/j<list.get(i))
					break;
			}

			ans=(ans%m*power(list.get(i),count,m))%m;

		}

		System.out.println(ans);

	}

	public static long power(long a,long b,long m)
	{
		long res=1;

		while(b>0)
		{
			if(b%2!=0)
			{
				res=(res%m*a%m)%m;
			}

			b=b/2;
			a=(a%m*a%m)%m;
		}

		return res;
	}

	public static void seive(boolean[] prime,int n)
	{
		Arrays.fill(prime,true);

		prime[0]=false;
		prime[1]=false;

		for(int i=2;i<=Math.sqrt(n);i++)
		{
			if(prime[i])
			{
				for(int j=i*i;j<=n;j=j+i)
				{
					prime[j]=false;
				}
			}
		}
	}

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();
            int k = in.readInt();
            int[] a = IOUtils.readIntArray(in, n);
            MiscUtils.decreaseByOne(a);
            HashSet<Integer> library = new HashSet<>();
            int res = 0;
            for (int want = 0; want < n; want++) {
                if (library.contains(a[want])) continue;
                res++;
                if (library.size() == k) {
                    int other = -1, far = -1;
                    for (int book : library) {
                        int dist = n;
                        for (int i = want + 1; i < n; i++) {
                            if (a[i] == book) {
                                dist = i;
                                break;
                            }
                        }
                        if (dist > far) {
                            far = dist;
                            other = book;
                        }
                    }
                    library.remove(other);
                }
                library.add(a[want]);
            }
            out.printLine(res);
        }
    }
    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(int i) {
            writer.println(i);
        }
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

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

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

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

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
    static class IOUtils {
        public static int[] readIntArray(InputReader in, int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++) {
                array[i] = in.readInt();
            }
            return array;
        }
    }
    static class MiscUtils {
        public static void decreaseByOne(int[]... arrays) {
            for (int[] array : arrays) {
                for (int i = 0; i < array.length; i++) {
                    array[i]--;
                }
            }
        }
    }
}


import java.util.*;
public class mohammad
{
  public static void main (String[]args)
  {
    Scanner U = new Scanner (System.in);
    int n = U.nextInt();
    int[] a = new int[n];
    int[] b = new int[n];
    for( int i=0 ; i<n ; i++)
        a[i] = U.nextInt();
    for( int j=0 ; j<n ; j++)
    for( int i=0 ; i<n ; i++)
        if(a[i]==a[j])
            b[j]++;
    Arrays.sort(b);
    if(b[n-1]==0||b[n-1]==1)
    System.out.println(1);
    else
        System.out.println(b[n-1]);
    }
}


import java.util.*;

public class IQ {
	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
		String[] arr = in.nextLine().split(" ");
		int[] ints = new int[4];
		for(int i = 0; i < arr.length; i++) {
			ints[i] = Integer.parseInt(arr[i]);
		}
		if(ints[1] * 2 == ints[0] + ints[2] && ints[2] * 2 == ints[1] + ints[3]) {
			System.out.println(ints[3] * 2 - ints[2]);
		} else {
			if(ints[1] * ints[1] == ints[0] * ints[2] && ints[2] * ints[2] == ints[1] * ints[3]) {
				double a = (double) ints[3] * ints[3] / ints[2];
				if(Math.round(a) != a) System.out.println(42);
				else System.out.println((int) Math.round(a));
			} else {
				System.out.println("42");
			}
		}
	}
}


import java.io.*;
import java.util.*;
public class Main{
    static int MOD=(int)1e9+7;
	public static void main (String[] args) {
	    Scanner sc=new Scanner(System.in);
	    String s=sc.next();
	    String t=sc.next();
	    int a=0,b=0;
	    while(a<s.length()&&b<t.length()){
	        if(s.charAt(a)==t.charAt(b)){a++;b++;}
	        else a++;
	        if(b==t.length()){System.out.println("automaton");return;}
	    }
	    if(s.indexOf(t)!=-1){
	        System.out.println("automaton");
	    }else{
	        int cnt1[]=new int[256];
	        int cnt2[]=new int[256];
	        boolean valid=true;
	        for(int i=0;i<s.length();i++)cnt1[s.charAt(i)-'a']++;
	        for(int i=0;i<t.length();i++)cnt2[t.charAt(i)-'a']++;
	        for(int i=0;i<256;i++)if(cnt1[i]<cnt2[i]){
	            valid=false;break;
	        }
	        if(valid&&s.length()>t.length())System.out.println("both");
	        else if(valid&&s.length()==t.length())System.out.println("array");
	        else System.out.println("need tree");
	    }
	}
}


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

public class B146 {

    public static void main(String[] args) throws IOException {
        new B146().run();
    }

    private void solve() throws IOException {
        int a = nextInt();
        int b = nextInt();
        int c = nextInt();

        long result = 0;

        cache = new int[a * b * c + 1];

        for (int i = 1; i <= a; i++)
            for (int j = 1; j <= b; j++)
                for (int k = 1; k <= c; k++)
                    result += countD(i * j * k);

        out.print(result);
    }

    //70 70 70 = 14425864
    int[] cache;

    long countD(int n) {
        int result = 0;
        if (cache[n] != 0) return cache[n];
        for (int i = 1; i * i <= n; i++)
        {
            if (n % i == 0)
            {
                result++;
                if (i != n / i)
                {
                    result++;
                }
            }
        }
        cache[n] = result;
        return result;
    }

    private PrintWriter out;
    private StringTokenizer st;
    private BufferedReader in;

    void run() {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in = new BufferedReader(new InputStreamReader(System.in));
        try
        {
            solve();
        } catch (Throwable e)
        {
            e.printStackTrace();
        } finally
        {
            try
            {
                in.close();
                out.close();
            } catch (IOException e)
            {
                e.printStackTrace();
            }
        }
    }

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

    private String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
        {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
}


import java.util.*;
public class Test1 {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-->0) {
			int ind = sc.nextInt();
			int[] arr = new int[3];
			arr[0] = sc.nextInt();
			arr[1] = sc.nextInt();
			arr[2] = sc.nextInt();
			int count = 1;

			while(arr[ind-1] != 0) {
				ind = arr[ind-1];
				count++;
			}

			if(count == 3)
				System.out.println("YES");
			else
				System.out.println("NO");

		}
	}
}


import java.awt.Point;
import java.io.*;
import java.util.*;
public class Contest1 {
	static PrintWriter out;
	static ArrayList<Integer> primes;
	static int p;
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		out = new PrintWriter(System.out);
		Scanner sc = new Scanner(System.in);
		p = sc.nextInt();
		int cnt = 0;
		mo:for(int i=1;i<p;i++) {
			int tmp = 1;
			for(int j=1;j<p;j++) {
				tmp = (tmp*i)%p;
				if(tmp%p == 1 && j < p-1)
					continue mo;
			}
			if(tmp%p == 1)
				cnt++;
		}
		out.println(cnt);
		out.flush();
	}
	static int pow(int n, int m) {
		if(m == 0) return 1;
		if(m == 1) return n;
		int ans = n;
		if(m%2 == 0) {
			int tmp = pow(ans,m/2);
			ans = tmp*tmp;
		}else {
			int tmp = pow(ans,--m);
			ans = n*tmp;
		}
		return ans;
	}
	static boolean isPrime(long n) {
		for(long i=2;i*i<=n;i++) {
			if(n%i == 0)
				return false;
		}
		return n>1;
	}
	static void sieveLinear(int N)
	{
		primes = new ArrayList<Integer>();
		int[] lp = new int[N + 1];								//lp[i] = least prime divisor of i
		for(int i = 2; i <= N; ++i)
		{
			if(lp[i] == 0)
			{
				primes.add(i);
				lp[i] = i;
			}
			int curLP = lp[i];
			for(int p: primes)
				if(p > curLP || p * i > N)
					break;
				else
					lp[p * i] = i;
		}
	}
	static int gcd(int a,int b) {
		if(a == 0)
			return b;
		return gcd(b % a,a);
	}
	static class Pair extends Point implements Comparable<Pair>
	{
		public Pair(int x, int y) {
			super(x,y);
		}
		@Override
		public int compareTo(Pair o) {
			// TODO Auto-generated method stub
			if(x == o.x)
				return y-o.y;
			return x-o.x;
		}

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


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

public class solve
{
	// Read a String from the standard input using Scanner
	// public static void main(String[] args)
	// {
	// 	Scanner scanner = new Scanner(System.in);
	// 	ArrayList<Integer> nums = new ArrayList<Integer>();
	// 	for(String tok : scanner.nextLine().split(" ")){
	// 		nums.add(Integer.parseInt(tok));

	// 	}

	// 	System.out.println(nums);
	// 	scanner.close();

	// }
	public static void fun(String s){

		char c = s.charAt(0);
		char num = s.charAt(1);

		int ret = 8;
		boolean flag = false;
		if(c == 'a' || c == 'h'){
			ret -= 3;
			flag = true;
		}

		if(num == '1' || num == '8'){
			if(flag){
				ret -= 2;
			}else{
				ret -= 3;
			}

		}
		System.out.println(ret);
	}

	public static void main(String[] args){

		FastReader fr = new FastReader();
		String s = fr.nextLine();
		fun(s);

	}

	static class FastReader
	{
	    BufferedReader br;
	    StringTokenizer st;

	    public FastReader() {
	    	br = new BufferedReader(new
	                 InputStreamReader(System.in));
	    }
	    String next() {
	        while (st == null || !st.hasMoreElements()) {
	            try{
	                st = new StringTokenizer(br.readLine());
	            }
	            catch (IOException  e) {
	                e.printStackTrace();
	            }
	        }
	        return st.nextToken();
	    }
	    int nextInt() {
	        return Integer.parseInt(next());
	    }
	    long nextLong() {
	        return Long.parseLong(next());
	    }
	    double nextDouble() {
	        return Double.parseDouble(next());
	    }
	    String nextLine() {
	        String str = "";
	        try{
	            str = br.readLine();
	        }
	        catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	    }
	}
}


import java.util.Scanner;

public class C911 {
	public static void main(String arsg[]) {
		Scanner skan = new Scanner(System.in);
		int k1=skan.nextInt(),k2=skan.nextInt(),k3=skan.nextInt();
		if (k1==1||k2==1||k3==1) {
			System.out.println("YES");
			return;
		}else if (k1==3&&k2==3&&k3==3) {System.out.println("YES");
		}else if ((k1==2&&k2==2)||(k1==2&&k3==2)||(k2==2&&k3==2)) {System.out.println("YES");
		}else if ((k1==4&&k2==4&&k3==2)||(k1==4&&k3==4&&k2==2)||(k2==4&&k3==4&&k1==2)||(k2==4&&k1==4&&k3==2)||(k3==4&&k1==4&&k2==2)||(k3==4&&k2==4&&k1==2)) {System.out.println("YES");
		}else {System.out.println("NO");
		}
	}
}


//Code by Sounak, IIEST
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.Arrays;
public class Test1{
    public static void main(String args[])throws IOException{
        FastReader sc = new FastReader();
        StringBuilder sb = new StringBuilder();
        int n=sc.nextInt();
        int sum=(n/2+1)*((int)Math.ceil(n/2.0));
        System.out.println(sum);
    }
}

class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); }
    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
    int nextInt() { return Integer.parseInt(next()); }
    long nextLong() { return Long.parseLong(next()); }
    double nextDouble() { return Double.parseDouble(next()); }
    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}


/*
╭╮╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╭╮╱╱╱╱╭╮╱╱╱╱╱╱╱╱╱╱╱╱╱╱╭╮╱╱╱╱╱╱╱╱╱╱╱╭╮╱╱╭╮╱╱╱╱╱╱╱╱╭╮╱╱╱╱╭╮╱╱╱╱╱╱╱╱╱╱╱╱╭╮╱╱╱╱╱╱╱╱╱╱╱╱╭━╮
┃┃╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱┃┃╱╱╱╭╯╰╮╱╱╱╱╱╱╱╱╱╱╱╱╱┃┃╱╱╱╱╱╱╱╱╱╱╱┃┃╱╱┃┃╱╱╱╱╱╱╱╱┃┃╱╱╱╭╯╰╮╱╱╱╱╱╱╱╱╱╱╱┃┃╱╱╱╱╱╱╱╱╱╱╱╱┃╭╯
┃┃╱╱╭━━┳╮╭┳━━╮╭╮╭╮╭┫╰━┳━┻╮╭╯╭╮╱╭┳━━┳╮╭╮╭━╯┣━━╮╭━━┳━╮╭━╯┃╭━╯┣━━╮╭╮╭╮╭┫╰━┳━┻╮╭╯╭╮╱╭┳━━┳╮╭╮┃┃╭━━┳╮╭┳━━╮╱╭╯╰┳━━┳━━┳╮╭┳━━╮
┃┃╱╭┫╭╮┃╰╯┃┃━┫┃╰╯╰╯┃╭╮┃╭╮┃┃╱┃┃╱┃┃╭╮┃┃┃┃┃╭╮┃╭╮┃┃╭╮┃╭╮┫╭╮┃┃╭╮┃╭╮┃┃╰╯╰╯┃╭╮┃╭╮┃┃╱┃┃╱┃┃╭╮┃┃┃┃┃┃┃╭╮┃╰╯┃┃━┫╱╰╮╭┫╭╮┃╭━┫┃┃┃━━┫
┃╰━╯┃╰╯┣╮╭┫┃━┫╰╮╭╮╭┫┃┃┃╭╮┃╰╮┃╰━╯┃╰╯┃╰╯┃┃╰╯┃╰╯┃┃╭╮┃┃┃┃╰╯┃┃╰╯┃╰╯┃╰╮╭╮╭┫┃┃┃╭╮┃╰╮┃╰━╯┃╰╯┃╰╯┃┃╰┫╰╯┣╮╭┫┃━╋┳┳┫┃┃╰╯┃╰━┫╰╯┣━━┃
╰━━━┻━━╯╰╯╰━━╯╱╰╯╰╯╰╯╰┻╯╰┻━╯╰━╮╭┻━━┻━━╯╰━━┻━━╯╰╯╰┻╯╰┻━━╯╰━━┻━━╯╱╰╯╰╯╰╯╰┻╯╰┻━╯╰━╮╭┻━━┻━━╯╰━┻━━╯╰╯╰━━┻┻┻┻╯╰━━┻━━┻━━┻━━╯
╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╭━╯┃╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╭━╯┃
╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╰━━╯╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╰━━╯
╱╱╱╱╱╱╱╱╭╮╱╱╱╱╱╱╭╮╱╱╱╱╱╭╮╱╭╮╱╱╱╱╱╱╱╱╱╭╮╱╱╱╱╱╱╱╱╭╮╱╭━╮╱╱╱╱╱╱╱╱╱╱╭╮╱╱╱╱╭╮╱╱╱╱╱╱╱╭╮╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╭╮╭╮
╱╱╱╱╱╱╱╭╯╰╮╱╱╱╱╱┃┃╱╱╱╱╭╯╰╮┃┃╱╱╱╱╱╱╱╱╱┃┃╱╱╱╱╱╱╱╱┃┃╱┃╭╯╱╱╱╱╱╱╱╱╱╭╯╰╮╱╱╱┃┃╱╱╱╱╱╱╭╯╰╮╱╱╱╱╱╱╱╱╱╱╱╱╱╱╭╯╰┫┃
╭━━┳━╮╱╰╮╭╋━━┳━━┫┃╭╮╭━┻╮╭╯┃╰━┳━━┳━╮╭━╯┃╭━━┳━╮╭━╯┃╭╯╰┳━━┳━┳━━┳━┻╮╭╯╭━━┫╰━┳━━┳╮┣╮╭╯╭━━┳╮╭┳━━┳━┳╮╱┣╮╭┫╰━┳┳━╮╭━━╮
┃╭╮┃╭╮╮╱┃┃┃╭╮┃━━┫╰╯╯┃╭╮┃┃╱┃╭╮┃╭╮┃╭╮┫╭╮┃┃╭╮┃╭╮┫╭╮┃╰╮╭┫╭╮┃╭┫╭╮┃╭╮┃┃╱┃╭╮┃╭╮┃╭╮┃┃┃┃┃╱┃┃━┫╰╯┃┃━┫╭┫┃╱┃┃┃┃╭╮┣┫╭╮┫╭╮┃
┃╰╯┃┃┃┃╱┃╰┫╭╮┣━━┃╭╮╮┃╭╮┃╰╮┃┃┃┃╭╮┃┃┃┃╰╯┃┃╭╮┃┃┃┃╰╯┃╱┃┃┃╰╯┃┃┃╰╯┃╰╯┃╰╮┃╭╮┃╰╯┃╰╯┃╰╯┃╰╮┃┃━╋╮╭┫┃━┫┃┃╰━╯┃╰┫┃┃┃┃┃┃┃╰╯┣┳┳╮
╰━━┻╯╰╯╱╰━┻╯╰┻━━┻╯╰╯╰╯╰┻━╯╰╯╰┻╯╰┻╯╰┻━━╯╰╯╰┻╯╰┻━━╯╱╰╯╰━━┻╯╰━╮┣━━┻━╯╰╯╰┻━━┻━━┻━━┻━╯╰━━╯╰╯╰━━┻╯╰━╮╭┻━┻╯╰┻┻╯╰┻━╮┣┻┻╯
╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╭━╯┃╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╭━╯┃╱╱╱╱╱╱╱╱╱╭━╯┃
╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╰━━╯╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╰━━╯╱╱╱╱╱╱╱╱╱╰━━╯
*/
import java.util.*;
import java.math.*;

public class Ekalavya {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		char[] ch = in.next().toCharArray();

		int k = in.nextInt();

		for (int i = 0; i < ch.length; i++) {

			int idx = -1;
			char max = ch[i];

			for (int j = i + 1; j < ch.length; j++) {

				if (ch[j] > max && j - i <= k) {
					max = ch[j];
					idx = j;
				}

			}

			if (idx != -1) {

				k -= (idx - i);

				for (int j = idx; j > i; j--) {
					char temp = ch[j];
					ch[j] = ch[j - 1];
					ch[j - 1] = temp;
				}

			}

		}

		for (int i = 0; i < ch.length; i++) {
			System.out.print(ch[i]);
		}

		System.out.println();

	}

}


import java.math.*;
import java.io.*;
import java.util.*;
/* Jai Shree Ram */
public class JAVA {

	static int gcd(int a, int b)
    {
      if (b == 0)
        return a;
      return gcd(b, a % b);
    }
	public static int func(int a , int b , int n)
	{
		int x = 1;
		int count = 1;
		while(true)
		{
			if(count % 2 != 0)
			{
				int q = gcd(a , n);
				n = n - q;
				if(n < 0)
				{
					return 0;
				}
				count++;
				x = 0;
			}
			else
			{

				int q = gcd(b , n);
				n = n - q;
				if(n < 0)
				{
					return 1;
				}
				count++;
				x = 1;
			}
			if(n == 0)
			{
				break;
			}
		}
		return x;
	}

	public static void main (String[] args) throws Exception
	 {
	 	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	 	//Scanner sc = new Scanner(System.in);

	 	String str[] = br.readLine().trim().split(" ");
	 	int a = Integer.parseInt(str[0]);
	 	int b = Integer.parseInt(str[1]);
	 	int n = Integer.parseInt(str[2]);
	 	System.out.println(func(a , b , n));
	 }

}


import java.util.Scanner ;
public class B_259_Little_Elephant_and_Magic_Square {
	public static void main(String[] args) {
		Scanner in = new Scanner (System.in);
		int [] z = new int [9];
		int m =0 ;
		for(int i = 0;i<z.length;i++){
			z[i]=in.nextInt();
			m+=z[i];
		}
		m/=2;
		z[0]=m-(z[1]+z[2]);
		z[4]=m-(z[3]+z[5]);
		z[8]=m-(z[7]+z[6]);
		for(int i =0 ;i<z.length;i+=3)
			System.out.println(z[i]+" "+z[i+1]+" "+z[i+2]);
	}
}


import java.util.*;
import java.io.*;
/**
 *
 * @author alanl
 */
public class Main{
    static BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;
    static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static void main(String[] args) throws IOException{
        long a = readLong(), b = readLong(), diff = b-a, sub = b, sub1 = diff;
        boolean zero = false;
        int cur = 0;
        while(cur<10 && sub1>0){
            sub--;
            sub1--;
            if(sub1==0)break;
            cur++;
            if(sub<1)break;
            if(sub%5==0){
                zero = true;
                break;
            }
        }
        if(zero){
            println(0);
            return;
        }
        else{
            String[]val = Long.toString(b).split("");
            int cnt = Integer.parseInt(val[val.length-1]);
            long ans = 1;
            while(cnt>=0&&diff>0){
                ans*=cnt;
                cnt--;
                diff--;
            }
            val = Long.toString(ans).split("");
            println(val[val.length-1]);
        }
    }
    static String next () throws IOException {
        while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(input.readLine().trim());
        return st.nextToken();
    }
    static long readLong () throws IOException {
        return Long.parseLong(next());
    }
    static int readInt () throws IOException {
        return Integer.parseInt(next());
    }
    static double readDouble () throws IOException {
        return Double.parseDouble(next());
    }
    static char readChar () throws IOException {
        return next().charAt(0);
    }
    static String readLine () throws IOException {
        return input.readLine().trim();
    }
    static void print(Object b) {
        System.out.print(b);
    }
    static void println(Object b) {
        System.out.println(b);
    }
    static void println() {
        System.out.println();
    }
}