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

/**
 * @author Egor Kulikov (egor@egork.net)
 */
public class TaskC {
    private static final double CERTAINTY = 0;

    @SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
    private final InputReader in;
    private final PrintWriter out;
    private final boolean testMode;

    private static class Rational {
        private final int a;
        private final int b;

        private Rational(int a, int b) {
            int g = gcd(a, b);
            this.a = a / g;
            this.b = b / g;
        }

        private int gcd(int a, int b) {
            while (b != 0) {
                int t = a % b;
                a = b;
                b = t;
            }
            return a;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;

            Rational rational = (Rational) o;

            return a == rational.a && b == rational.b;

        }

        @Override
        public int hashCode() {
            int result = a;
            result = 31 * result + b;
            return result;
        }
    }

    private void solve() {
        int[] array = new int[50000000];
        array = null;
        array = new int[50000000];
    }

    private int reverse(int v) {
        int result = 0;
        while (v != 0) {
            result *= 10;
            result += v % 10;
            v /= 10;
        }
        return result;
    }

    public static class IntervalTree {
        private int[] left;
        private int[] right;
        private int[] value;

        public IntervalTree(int size) {
            left = new int[4 * size];
            right = new int[4 * size];
            value = new int[4 * size];
            init(0, size, 0);
        }

        private void init(int left, int right, int root) {
            this.left[root] = left;
            this.right[root] = right;
            if (right - left > 1) {
                init(left, (left + right) / 2, 2 * root + 1);
                init((left + right) / 2, right, 2 * root + 2);
            }
        }

        public int lowerBound(int value) {
            return lowerBound(value, 0);
        }

        private int lowerBound(int value, int root) {
            if (right[root] - left[root] == 1)
                return left[root];
            if (this.value[2 * root + 1] >= value)
                return lowerBound(value, 2 * root + 1);
            return lowerBound(value - this.value[2 * root + 1], 2 * root + 2);
        }

        public void putValue(int position, int value) {
            putValue(position, value, 0);
        }

        private void putValue(int position, int value, int root) {
            if (left[root] > position || right[root] <= position)
                return;
            this.value[root] += value;
            if (right[root] - left[root] > 1) {
                putValue(position, value, 2 * root + 1);
                putValue(position, value, 2 * root + 2);
            }
        }
    }

    private static List<Test> createTests() {
        List<Test> tests = new ArrayList<Test>();
        tests.add(new Test("2 2 1", "1 1"));
        tests.add(new Test("132 10 35", "7 5"));
        tests.add(new Test("5 18 1000", "-1"));
        tests.add(new Test("48 132 235", "22 111"));
        tests.add(new Test("100000 100000 1", "1 1"));
//      tests.add(new Test("", ""));
//      tests.add(new Test("", ""));
//      tests.add(new Test("", ""));
//      tests.add(new Test("", ""));
//      tests.add(new Test("", ""));
//      tests.add(new Test("", ""));
//      tests.add(new Test("", ""));
//      tests.add(new Test("", ""));
//      tests.add(new Test("", ""));
//      tests.add(new Test("", ""));
//      tests.add(new Test("", ""));
//      tests.add(new Test("", ""));
//      tests.add(new Test("", ""));
//      tests.add(new Test("", ""));
//      tests.add(new Test("", ""));
        return tests;
    }

    private void run() {
        //noinspection InfiniteLoopStatement
//      while (true)
//      int testCount = in.readInt();
//      for (int i = 0; i < testCount; i++)
        solve();
        exit();
    }

    private TaskC() {
        @SuppressWarnings({"UnusedDeclaration"})
        String id = getClass().getName().toLowerCase();
        //noinspection EmptyTryBlock
        try {
//          System.setIn(new FileInputStream(id + ".in"));
//          System.setOut(new PrintStream(new FileOutputStream(id + ".out")));
//          System.setIn(new FileInputStream("input.txt"));
//          System.setOut(new PrintStream(new FileOutputStream("output.txt")));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        in = new StreamInputReader(System.in);
        out = new PrintWriter(System.out);
        testMode = false;
    }

    @SuppressWarnings({"UnusedParameters"})
    private static String check(String input, String result, String output) {
//      return strictCheck(result, output);
        return tokenCheck(result, output);
    }

    public static void main(String[] args) {
//        if (args.length != 0 && args[0].equals("42"))
            test();
//        else
//            new TaskC().run();
    }

    private static void test() {
        System.setProperty("line.separator", "\n");
        List<Test> tests = createTests();
        int testCase = 0;
        List<Verdict> verdicts = new ArrayList<Verdict>();
        long maximalTime = 0;
        boolean ok = true;
        for (Test test : tests) {
            System.out.println("Test #" + testCase + ":");
            InputReader in = new StringInputReader(test.getInput());
            StringWriter out = new StringWriter(test.getOutput().length());
            System.out.println("Input:");
            System.out.println(test.getInput());
            System.out.println("Expected output:");
            System.out.println(test.getOutput());
            System.out.println("Execution result:");
            long time = System.currentTimeMillis();
            try {
                new TaskC(in, new PrintWriter(out)).run();
            } catch (TestException e) {
                time = System.currentTimeMillis() - time;
                maximalTime = Math.max(time, maximalTime);
                String result = out.getBuffer().toString();
                System.out.println(result);
                System.out.print("Verdict: ");
                String checkResult = check(test.getInput(), result, test.getOutput());
                if (checkResult == null) {
                    System.out.print("OK");
                    verdicts.add(Verdict.OK);
                } else {
                    System.out.print("WA (" + checkResult + ")");
                    verdicts.add(Verdict.WA);
                    ok = false;
                }
                System.out.printf(" in %.3f s.\n", time / 1000.);
            } catch (Throwable e) {
                System.out.println("Exception thrown:");
                e.printStackTrace(System.out);
                verdicts.add(Verdict.RTE);
                ok = false;
            }
            testCase++;
            System.out.println("------------------------------------------------------------------");
        }
        System.out.println("==================================================================");
        System.out.println("Test results:");
        if (ok)
            System.out.printf("All test passed in %.3f s.\n", maximalTime / 1000.);
        else {
            for (int i = 0; i < verdicts.size(); i++)
                System.out.println("Test #" + i + ": " + verdicts.get(i));
        }
    }

    private static enum Verdict {
        OK, WA, RTE
    }

    private static String tokenCheck(String result, String output) {
        StringInputReader resultStream = new StringInputReader(result);
        StringInputReader outputStream = new StringInputReader(output);
        int index = 0;
        boolean readingResult = false;
        try {
            while (true) {
                readingResult = true;
                String resultToken = resultStream.readString();
                readingResult = false;
                String outputToken = outputStream.readString();
                if (!resultToken.equals(outputToken)) {
                    try {
                        //noinspection PointlessBooleanExpression
                        if (CERTAINTY != 0 && isDoubleEquals(Double.parseDouble(outputToken.replace(',', '.')),
                                Double.parseDouble(resultToken.replace(',', '.')), CERTAINTY))
                        {
                            index++;
                            continue;
                        }
                    } catch (NumberFormatException ignored) {}
                    return "'" + outputToken + "' expected at " + index + " but '" + resultToken + "' received";
                }
                index++;
            }
        } catch (InputMismatchException e) {
            if (readingResult) {
                try {
                    outputStream.readString();
                    return "only " + index + " tokens received";
                } catch (InputMismatchException e1) {
                    return null;
                }
            } else
                return "only " + index + " tokens expected";
        }
    }

    @SuppressWarnings({"UnusedDeclaration"})
    private static String strictCheck(String result, String output) {
        if (result.equals(output))
            return null;
        return "Result and expected output do not match";
    }

    @SuppressWarnings({"UnusedDeclaration"})
    private static boolean isDoubleEquals(double expected, double result, double certainty) {
        return Math.abs(expected - result) < certainty || Math.abs(expected - result) < certainty * expected;
    }

    private TaskC(InputReader in, PrintWriter out) {
        this.in = in;
        this.out = out;
        testMode = true;
    }

    @SuppressWarnings({"UnusedDeclaration"})
    private void exit() {
        out.close();
        if (testMode)
            throw new TestException();
        System.exit(0);
    }

    private static class Test {
        private final String input;
        private final String output;

        private Test(String input, String output) {
            this.input = input;
            this.output = output;
        }

        public String getInput() {
            return input;
        }

        public String getOutput() {
            return output;
        }
    }

    @SuppressWarnings({"UnusedDeclaration"})
    private abstract static class InputReader {
        public abstract int read();

        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 long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long 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 String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

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

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

        public String readLine() {
            String s = readLine0();
            while (s.trim().length() == 0)
                s = readLine0();
            return s;
        }

        public String readLine(boolean ignoreEmptyLines) {
            if (ignoreEmptyLines)
                return readLine();
            else
                return readLine0();
        }

        public BigInteger readBigInteger() {
            try {
                return new BigInteger(readString());
            } catch (NumberFormatException e) {
                throw new InputMismatchException();
            }
        }

        public char readCharacter() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            return (char) c;
        }

        public double readDouble() {
            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, readInt());
                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, readInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public int[] readIntArray(int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
                array[i] = readInt();
            return array;
        }

        public long[] readLongArray(int size) {
            long[] array = new long[size];
            for (int i = 0; i < size; i++)
                array[i] = readLong();
            return array;
        }

        public double[] readDoubleArray(int size) {
            double[] array = new double[size];
            for (int i = 0; i < size; i++)
                array[i] = readDouble();
            return array;
        }

        public String[] readStringArray(int size) {
            String[] array = new String[size];
            for (int i = 0; i < size; i++)
                array[i] = readString();
            return array;
        }

        public char[][] readTable(int rowCount, int columnCount) {
            char[][] table = new char[rowCount][columnCount];
            for (int i = 0; i < rowCount; i++) {
                for (int j = 0; j < columnCount; j++)
                    table[i][j] = readCharacter();
            }
            return table;
        }

        public void readIntArrays(int[]... arrays) {
            for (int i = 0; i < arrays[0].length; i++) {
                for (int j = 0; j < arrays.length; j++)
                    arrays[j][i] = readInt();
            }
        }
    }

    private static class StreamInputReader extends InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar, numChars;

        public StreamInputReader(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++];
        }
    }

    private static class StringInputReader extends InputReader {
        private Reader stream;
        private char[] buf = new char[1024];
        private int curChar, numChars;

        public StringInputReader(String stream) {
            this.stream = new StringReader(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++];
        }
    }

    private static class TestException extends RuntimeException {}
}


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

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

/* Name of the class has to be "Main" only if the class is public. */
public class C
{
    public static long gcd(long a, long b){
        if(a>b){
            long c=a;
            a=b;
            b=c;
        }
        if(b%a==0)return a;
        return gcd(a,b-a);
    }
    public static void main (String[] args) throws Exception
    {
        Scanner s = new Scanner(System.in);
        StringTokenizer st = new StringTokenizer(s.nextLine());
        BigInteger t = new BigInteger(st.nextToken());
        BigInteger w = new BigInteger(st.nextToken());
        BigInteger b = new BigInteger(st.nextToken());
        BigInteger prod = b.multiply(w);
        BigInteger div = t.divide(prod);
        BigInteger rem = t.mod(prod);
        BigInteger one = new BigInteger("1");
        long den=t.longValue();
        BigInteger numm = (div.multiply(w.min(b))).subtract(one).add(rem.min(w.min(b)));
        long num = numm.longValue();
        if(num==0){
            System.out.println("0/1");
            System.exit(0);
        }
        else System.out.println(num/gdi+"/"+den/gdi);
    }
}


import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;

import com.sun.org.apache.bcel.internal.generic.SWAP;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		BigInteger t = in.nextBigInteger();
		BigInteger a = in.nextBigInteger();
		BigInteger b = in.nextBigInteger();

		BigInteger tmp;
		if (a.compareTo(b) > 0) {
			tmp = a;
			a = b;
			b = tmp;
		}

		BigInteger lcm = a.multiply(b).divide(a.gcd(b));

		BigInteger ans;
		if (t.compareTo(lcm) >= 0) {
			tmp = t.mod(lcm).add(BigInteger.ONE);
			if (tmp.compareTo(a) > 0) tmp = a;
			ans = t.divide(lcm).subtract(BigInteger.ONE).multiply(a).add(tmp).add(a.subtract(BigInteger.ONE));
		}
		else {
			ans = max(t,a.subtract(BigInteger.ONE));
		}

		tmp = ans.gcd(t);
		ans = ans.divide(tmp);
		t = t.divide(tmp);
		System.out.println(ans+"/"+t);
	}
}


import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main{

static PrintWriter out;
static InputReader ir;
static final int INF=Integer.MAX_VALUE;
static final long LINF=Long.MAX_VALUE;

static void solve(){
 BigInteger nn=ir.nextBigInteger();
 BigInteger a=ir.nextBigInteger();
 BigInteger b=ir.nextBigInteger();
 BigInteger l=lcm(a,b);
 long mi=Math.min(a.longValue(),b.longValue());
 if(l.compareTo(n)>0){
  mi--;
  BigInteger mm=BigInteger.valueOf(mi);
  BigInteger gg=gcd(mm,n);
  out.println(mm.divide(gg)+"/"+n.divide(gg));
  return;
 }
 long ll=l.longValue();
 long nn=n.longValue();
 long d=nn/ll+1;
 long cnt=d*mi-1;
 if(nn<ll*(d-1)+mi-1) cnt-=ll*(d-1)+mi-1-nn;
 long g=lgcd(cnt,nn);
 out.println(cnt/g+"/"+nn/g);
}

public static void main(String[] args) throws Exception{
 ir=new InputReader(System.in);
 out=new PrintWriter(System.out);
 solve();
 out.flush();
}

public static BigInteger gcd(BigInteger a,BigInteger b){
 if(b.compareTo(BigInteger.ZERO)==0) return a;
 return gcd(b,a.remainder(b));
}

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

public static BigInteger lcm(BigInteger a,BigInteger b){return a.multiply(b)/.divide(gcd(a,b));}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;

 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}

 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }

 private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}

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

 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}

 public boolean hasNext(){skip(); return hasNextByte();}

 public String next(){
  if(!hasNext()) throw new NoSuchElementException();
  StringBuilder sb=new StringBuilder();
  int b=readByte();
  while(!isSpaceChar(b)){
   sb.appendCodePoint(b);
   b=readByte();
  }
  return sb.toString();
 }

 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }

 public long nextLong() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  long res = 0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }

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

 public BigInteger nextBigInteger(){return new BigInteger(next());}

 public BigDecimal nextBigDecimal(){return new BigDecimal(next());}

 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 char[][] nextCharMap(int n,int m){
  char[][] map=new char[n][m];
  for(int i=0;i<n;i++) map[i]=next().toCharArray();
  return map;
 }
}
}


import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main{

static PrintWriter out;
static InputReader ir;
static final int INF=Integer.MAX_VALUE;
static final long LINF=Long.MAX_VALUE;

static void solve(){
 BigInteger nn=ir.nextBigInteger();
 BigInteger a=ir.nextBigInteger();
 BigInteger b=ir.nextBigInteger();
 BigInteger l=lcm(a,b);
 long mi=Math.min(a.longValue(),b.longValue());
 if(l.compareTo(n)>0){
  mi--;
  BigInteger mm=BigInteger.valueOf(mi);
  BigInteger gg=gcd(mm,n);
  out.println(mm.divide(gg)+"/"+n.divide(gg));
  return;
 }
 long ll=l.longValue();
 long nn=n.longValue();
 long d=nn/ll+1;
 long cnt=d*mi-1;
 if(nn<ll*(d-1)+mi-1) cnt-=ll*(d-1)+mi-1-nn;
 long g=lgcd(cnt,nn);
 out.println(cnt/g+"/"+nn/g);
}

public static void main(String[] args) throws Exception{
 ir=new InputReader(System.in);
 out=new PrintWriter(System.out);
 solve();
 out.flush();
}

public static BigInteger gcd(BigInteger a,BigInteger b){
 if(b.compareTo(BigInteger.ZERO)==0) return a;
 return gcd(b,a.remainder(b));
}

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

public static BigInteger lcm(BigInteger a,BigInteger b){return a.multiply(b).divide(gcd(a,b));}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;

 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}

 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }

 private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}

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

 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}

 public boolean hasNext(){skip(); return hasNextByte();}

 public String next(){
  if(!hasNext()) throw new NoSuchElementException();
  StringBuilder sb=new StringBuilder();
  int b=readByte();
  while(!isSpaceChar(b)){
   sb.appendCodePoint(b);
   b=readByte();
  }
  return sb.toString();
 }

 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }

 public long nextLong() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  long res = 0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }

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

 public BigInteger nextBigInteger(){return new BigInteger(next());}

 public BigDecimal nextBigDecimal(){return new BigDecimal(next());}

 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 char[][] nextCharMap(int n,int m){
  char[][] map=new char[n][m];
  for(int i=0;i<n;i++) map[i]=next().toCharArray();
  return map;
 }
}
}


import java.io.OutputStream;
import java.util.Scanner;
import java.io.PrintWriter;

public class B {
    public static void main(String[] args) {
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB task = new TaskB();
        task.solve(in, out);
        out.close();
    }
}

class TaskB {

	public void solve(Scanner in, PrintWriter out) {
    	long w = in.nextLong();
    	long m = in.nextLong();
    	long k = in.nextLong();

    	long result = 0;
    	while(true){
    		long s = ((long) Math.log10(m)) + 1;
	    	long cost = s*k;

	    	if(w >= cost){
	    		result++;
	    		w -= cost;
	    		m++;
	    	}
	    	else break;
    	}

    	System.out.println(result);
    }

    // s(n) is the logarithm in base 10

}


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

//package codeforces;

import java.util.Scanner;

/**
 *
 * @author Айдос
 */
public class Main{
    public static void main(String [] args){

     Scanner sc = new Scanner(System.in);

    long w = sc.nextLong();
    long m = sc.nextLong();
     long k = sc.nextLong();
     w/=k;

     w+= get(m-1);
     long m1=m+1;
     while(get(m1)<=w){
      m1++;
     }
     System.out.println(m1-m);
    }
    public static long get(long a){
     long t=1;
     long now=1;
     long ret =0;
     for(;;){
      if(now*10>a){

      ret+=(a-now+1)*t;
      return ret;

      }
       ret+=now*9*t;
      now*=10;
      t++;
     }
    }
}


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

//package codeforces;

import java.util.Scanner;

/**
 *
 * @author Айдос
 */
public class Main{
    public static void main(String [] args){
     Scanner sc = new Scanner(System.in);

    long w = sc.nextLong();
    long m = sc.nextLong();
     long k = sc.nextLong();
     w/=k;

     w+= get(m-1);
     long m1=m+1;
     while(get(m1)<=w){
      m1++;
     }
     System.out.println(get(m1-m));
    }
    public static long get(long a){
     long t=1;
     long now=1;
     long ret =0;
     for(;;){
      if(now*10>a){

      ret+=(a-now+1)*t;
      return ret;

      }
       ret+=now*9*t;
      now*=10;
      t++;
     }
    }
}


import java.util.*;

public class R219Div2QB {
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		String stringInput[] = s.nextLine().split(" ");
		Long[] inputs = {Long.parseLong(stringInput[0]), Long.parseLong(stringInput[1]), Long.parseLong(stringInput[2])};
		Long w = inputs[0];
		Long m = inputs[1]-1;
		Long k = inputs[2];
		ArrayList<Long> sq = new ArrayList<Long>();
		while(w >= k){
			m++;
			w -= s(m) * k;
			if(w < 0)
				break;
			sq.add(m);
		}
		System.out.println(sq.size());
		s.close();
	}
	public static int s(Long n){
		return n.toString().length();
	}
}


import java.util.Scanner;

public class test {

	static int dirx[]={0,1,1,1, 0, -1,-1,-1};
	static int diry[]={1,1,0,-1,-1,-1, 0,1 };
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		boolean head[][][][] = new boolean[33][330][330][10];
		head[1][150][150][0] = true;
		int cnt = 0,t;
		boolean ok[][] = new boolean[330][330];
		int n = in.nextInt();
		for (int i = 1; i <= n; i++) {
			t = in.nextInt();
			for(int j=0;j<=300;j++){
				for(int k=0;k<=300;k++){
					for(int d=0;d<8;d++){
						if(head[i][j][k][d]==true){
							//System.out.println(j+" "+k+" "+d);
							int xx=j,yy=k;
							for(int g=0;g<t;g++){
								xx+=dirx[d];
								yy+=diry[d];
								if(ok[xx][yy]==false) cnt++;
								ok[xx][yy]=true;
							}
							head[i+1][xx][yy][(d+1)&7]=true;
							head[i+1][xx][yy][(d+7)&7]=true;
						}
					}
				}
			}
		}
		System.out.println(cnt);
	}
}
→Протокол тестирования


public class Task750D {

    private FastScanner in;

    private PrintWriter out;

    private int _depth;

    private int[] _lifespan;

    private int _count=0;

    private Coordinate[] _directions ={new Coordinate(0,1),new Coordinate(1,1),new Coordinate(1,0),new Coordinate(1,-1),new Coordinate(0,-1),new Coordinate(-1,-1),new Coordinate(-1,0),new Coordinate(-1,1)};

    private boolean[][][][] _visited= new boolean[310][310][8][32];

    private boolean _coordsVisited[][]=new boolean[310][310];

    private void run(){
        in=new Task750D.FastScanner("out/production/algoritmPractice/ru/nocompany/750dmax.txt");
        out = new PrintWriter(System.out);
        init();
        solve();
        out.close();
    }

    private void init(){
        _depth=in.nextInt();
        _lifespan=new int[_depth];
        for (int i=0;i<_depth;i++){
            _lifespan[i]=in.nextInt();
        }
    }

    private void solve() {
        Coordinate start=new Coordinate(151,151);
        int direction=0;
        int iteration=0;
        fly(start,direction,iteration);
        out.println(_count);
    }

    private void fly(Coordinate start, int directionNum, int iteration) {
        int lifespan=_lifespan[iteration];
        Coordinate current=start;
        Coordinate direction= _directions[directionNum];
        if (!visit(current,directionNum,iteration)){
            return;
        }
        for (int i=0;i<lifespan;i++){
            current=current.add(direction);
            visitCoord(current);
        }
        iteration++;
        if (iteration<_depth){
            fly(current,(directionNum+7)%8,iteration);
            fly(current,(directionNum+1)%8,iteration);
        }
    }

    private boolean visit(Coordinate c,int direction,int iteration){
        if (!_visited[c.getX()][c.getY()][direction][iteration]){
            _visited[c.getX()][c.getY()][direction][iteration]=true;
            return true;
        }
        return false;
    }

    private void visitCoord(Coordinate c){
        if (!_coordsVisited[c.getX()][c.getY()]) {
            _coordsVisited[c.getX()][c.getY()] = true;
            _count++;
        }
    }

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

    private class Coordinate {

        private final int _x;

        private final int _y;

        Coordinate(int x,int y){
            _x=x;
            _y=y;
        }

        Coordinate add(Coordinate direction){
            return new Coordinate(_x+direction.getX(),_y+direction.getY());
        }

        int getX() {
            return _x;
        }

        int getY() {
            return _y;
        }

        @Override
        public int hashCode() {
            return _x+31*_y;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj instanceof Coordinate){
                Coordinate objCoord=(Coordinate)obj;
                return _x==objCoord.getX() && _y==objCoord.getY();
            }
            return super.equals(obj);
        }

    }

    private class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(String fileName) {
            try {
                File file=new File(fileName);
                br = new BufferedReader(new FileReader(file));
            } catch (FileNotFoundException e) {
                throw new RuntimeException(e);
            }
        }

        @SuppressWarnings("unused")
        FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //what can i do?
                }
            }
            return st.nextToken();
        }

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

        @SuppressWarnings("unused")
        long nextLong() {
            return Long.parseLong(nextToken());
        }

        @SuppressWarnings("unused")
        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

}


import java.util.*;

public class Main
{
    public static long spaces = 0;
    public static HashSet<Long> set;
    public static int[][] dirs;

    public static long encode(long x, long y) {
        long xx = x >= 0 ? x * 2 : x * -2 - 1;
        long yy = y >= 0 ? y * 2 : y * -2 - 1;

        return (xx >= yy) ? (xx * xx + xx + yy) : (yy * yy + xx);
    }

    public static void solveBranch(int[] spaces, int spaceLen, long x, long y, int indexDir, int index) {
        int incX = dirs[indexDir][0];
        int incY = dirs[indexDir][1];

        int incAmt = spaces[index];

        long newX = x + incX*incAmt;
        long newY = y + incY*incAmt;

        long enc = encode(newX, newY);

        for (int i = 1; i <= incAmt; i++) {
            set.add(encode(x + incX*i, y + incY*i));
        }

        if (index == spaceLen - 1) return;

        int leftDir = indexDir == 0 ? 7 : indexDir - 1;
        int rightDir = (indexDir + 1) % 8;

        solveBranch(spaces, spaceLen, newX, newY, leftDir, index + 1);
        solveBranch(spaces, spaceLen, newX, newY, rightDir, index + 1);
    }

    public static long solve(int depth, int[] spaces) {
        int maxSize = 0;

        for (int i = 0; i < depth; i++) {
            maxSize += spaces[i]*Math.pow(2, i);
        }

        set = new HashSet<Long>(maxSize);

        solveBranch(spaces, depth, 0, 0, 0, 0);

        return set.size();
    }
	public static void main(String[] args) {
	    dirs = new int[][]{
	        {0, 1},
	        {1, 1},
	        {1, 0},
	        {1, -1},
	        {0, -1},
	        {-1, -1},
	        {-1, 0},
	        {-1, 1}
	    };

	    Scanner scan = new Scanner(System.in);

	    int depth = scan.nextInt();
	    int[] spaces = new int[depth];

	    for (int i = 0; i < depth; i++) {
	        spaces[i] = scan.nextInt();
	    }

	    System.out.println(solve(depth, spaces));
	}
}


import java.util.*;
import java.io.*;
import java.math.*;
public class code2 {
	InputStream is;
	PrintWriter out;
	ArrayList<Integer> al[];
	long mod=(int)Math.pow(10,9)+7;
	boolean dp[][][][][];int a[];
	void solve()
	{
		int n=ni();
		dp=new boolean[301+1][301+1][7][8][n];
		a=na(n);
		visited=new boolean[301+1][301+1];
		rec(155,155,a[0],2,0);
		int count=0;
		for(int i=0;i<=301;i++)
		{
			for(int j=0;j<=301;j++)
			{
				if(visited[i][j])
					count++;
			}
		}
		out.print(count);
	}
	boolean visited[][];
	void rec(int x,int y,int used,int dir,int level)
	{
		//if(used<0||level>=a.length)
			//return;
		if(dp[x][y][used][dir][level])
			return ;
		visited[x][y]=true;
		dp[x][y][used][dir][level]=true;
		if(used!=1)
		{
			int gox=x+getx(dir);
			int goy=y+gety(dir);
			rec(gox,goy,used-1,dir,level);
		}else{
			if(level+1<a.length) {
				rec(x,y,a[level+1]+1,(dir+1)%8,level+1);
				rec(x,y,a[level+1]+1,(dir-1+8)%8,level+1);
			}
		}
	}
	int getx(int dir)
	{
		if(dir==1||dir==2||dir==3)
			return -1;
		if(dir==5||dir==6|dir==7)
			return 1;
		return 0;
	}
	int gety(int dir)
	{
		if(dir==1||dir==0||dir==7)
			return 1;
		if(dir==3||dir==4|dir==5)
			return -1;
		return 0;
	}
	boolean isPrime(int num)
	{
		for(int i=2;i*i<=num;i++)
		{
			if(num%i==0)
				return false;
		}
		return true;
	}
	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>{

	        int x,y,k,i;

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

		public int compareTo(Pair o) {
					return this.y-o.y;
		}

	        public boolean equals(Object o) {
	            if (o instanceof Pair) {
	                Pair p = (Pair)o;
	                return p.x == x && p.y == y && p.k==k;
	            }
	            return false;
	        }

	        @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(y==0)
			return x;
		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 code2().run();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}, "1", 1 << 26).start();

	    	//new code2().run();
		}

	    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 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();
			}
		}

}


import java.io.*;

public class badges {

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

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int b = Integer.parseInt(br.readLine());
int g = Integer.parseInt(br.readLine());
int n=Integer.parseInt(br.readLine());

else{
if(b<g){
   if(b<n){if(b==g){
    System.out.println(1);
}
else{
       System.out.println(b+1);
}

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

    System.out.println(g+1);

}

}
	}
}


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

/**
 *
 * @author Asus
 */
import java.util.Scanner;

public class badges {
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n_b,n_g,n_t,a,b,i,t=0;
        n_b=sc.nextInt();
        n_g=sc.nextInt();
        n_t=sc.nextInt();
        b=n_t;
        a=0;
        for(i=0;i<(n_t+1);i++)
        {
            if(a>n_b)
            {
                break;
            }
            if(b>n_g)
            {
                b=n_g;
                i=n_t-n_g;
                a=i;
            }
            if(b<=n_g && a<=n_b)
            {
                t++;
            }

            a++;
            s
        }
        System.out.println(t);
    }
}


    import java.util.*;
    public class Main {

        public static void main(String args[]) {
            Scanner scan = new Scanner(System.in);
            int b=scan.nextInt();
            int g=scan.nextInt();
            int n=scan.nextInt();
            if (Math.min(b,g)>=n){
                System.out.println(Math.min(b,g)+1);
            }else (Math.min(b,g)<n){
                System.out.println(n+1);
            }

        }
    }


import java.io.*;

public final class solution
{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int b = Integer.parseInt(br.readLine().trim());
    int g = Integer.parseInt(br.readLine().trim());
    int n = Integer.parseInt(br.readLine().trim());
    int num = 0;
    for(int i = 0;i<=n;i++)
    {
        if(i<=b && n-i<=g){num++;}
    }
    System.out.println(num);
}


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.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class A {

	static StringTokenizer st;
	static BufferedReader br;
	static PrintWriter pw;
	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		int n = nextInt();
		int k = nextInt();
		int[]a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		int ans = 0;
		Set<Integer> inLibrary = new HashSet<>();
		int[]first = new int[n];
		for (int i = 0; i < n; i++) {
			if (!inLibrary.contains(a[i])) {
				ans++;
				if (inLibrary.size() < k)
					inLibrary.add(a[i]);
				else {
					Arrays.fill(first, n);
					for (int j = n-1; j > i; j--) {
						first[a[j]] = j;
					}
					int maxDay = 0, whatBook = 0;
					for (int j : inLibrary) {
						if (first[j] > maxDay) {
							maxDay = first[j];
							whatBook = j;
						}
					}
					inLibrary.remove(whatBook);
					inLibrary.add(a[i]);
				}
			}
		}
		System.out.println(ans);
		pw.close();
	}
	private static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	private static long nextLong() throws IOException {
		return Long.parseLong(next());
	}
	private static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}
	private static String next() throws IOException {
		while (st==null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}
}


import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Scanner;

public class B {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] A = new int[N];
    ArrayList<ArrayList<Integer>> next = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      A[i] = Integer.parseInt(sc.next());
      next.add(new ArrayList<>());
      next.get(i).add(1 << 29);
    }
    for (int i = N - 1; i >= 0; i--) {
      next.get(A[i]).add(i);
    }
    PriorityQueue<Integer> q = new PriorityQueue<>((Integer i1, Integer i2) -> {
      ArrayList<Integer> l1 = next.get(i1);
      ArrayList<Integer> l2 = next.get(i2);
      return -Integer.compare(l1.get(l1.size() - 1), l2.get(l2.size() - 1));
    });

    int ans = 0;
    for (int i = 0; i < N; i++) {
      if (q.contains(A[i])) {
        q.remove(A[i]);
        next.get(A[i]).remove(next.get(A[i]).size() - 1);
        q.add(A[i]);
      } else {
        ++ans;
        next.get(A[i]).remove(next.get(A[i]).size() - 1);
        if (q.size() == K) {
          q.poll();
        }
        q.add(A[i]);
      }
    }
    System.out.println(ans);
  }

  static int solve() {
    return 0;
  }

}


import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

public class Hiedi_and_library {
    public static void main(String[] a){
        Scanner sc=new Scanner(System.in);
      int n=sc.nextInt();
      int c=sc.nextInt();
      int cost=0;
      ArrayList ar=new ArrayList();
     ArrayList cr=new ArrayList();
      for(int i=0;i<n;i++){
      ar.add(sc.nextInt());
      }

      Iterator i=ar.listIterator();

      while(i.hasNext()){
          int v=(int)i.next();
      if(!cr.contains(v) && (cr.size()!=c)){
      cr.add(v);
      cost=cost+1;

      }
      else if(!cr.contains(v) && (cr.size()==c)){
      Iterator j=cr.listIterator();
      int max=0;
      int notexist=0;
      while(j.hasNext()){
          int t=(int)j.next();
          if((int)ar.indexOf(t)==-1){
          max=cr.indexOf(t);
          notexist=1;
          }
          if((int)ar.indexOf(t)>max && j.hasNext() && ((int)ar.indexOf(t))!=-1){
      max=ar.indexOf(t);
              }
      }
     // int replace=(int)ar.get(max);

     if(max==0 || notexist==1){cr.set(max,v);
     cost=cost+1;
     }
     else{
      int index=cr.indexOf(ar.get(max));
      cr.set(index,v);
     cost=cost+1;}

      }
      i.remove();
      }
      System.out.println(cost);
    }

}


/*628*/
import java.util.*;
public class tennis{

	public static void main(String[] args){

		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int b = input.nextInt();
		int p = input.nextInt();

		int bottles = 0;
		int towels = 0;

		bottles = 2*b + 1; //b = number of bottles for each player + 1 for official
		bottles = bottles * (n-1);// * number of players playing - 1
		towels = p*n; //p= number for each player * players total
		System.out.println(bottles+" "+towels);
		input.close();
	}

	}
}


import java.util.*;
public class CF 628A {
   public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      int n = scan.nextInt();
      int b = scan.nextInt();
      int p = scan.nextInt();

      int towels = p*n;
      int bottles = 0;
      while (n>1) {
         int pass = n%b;
         int matches = n/2;
         bottles += (b * 2 + 1) * matches;
        n = pass + matches;
      }
      System.out.println(bottles + " " + towels);
   }
}


import java.util.*;
public class me {
	public static void main(String[] args) {
		Scanner br = new Scanner(System.in);
	int n=br.nextInt();
	int[] arr=new int[n];
	int k=br.nextInt();
	for(i=0;i<n;i++)
	{
	    arr[i]=i+1;
	}
	if(n%2==0)
	{
	    if(k<=n/2)
	    System.out.print(n+(n-1));
	    else
	    System.out.print(n-(k-n));
	}
	else if(n%2!=0)
	{
	     if(k<=(n/2)+1))
	    System.out.print(n+(n-1));
	    else
	    System.out.print(n-(k-n));
	}
	}
}


import java.util.*;

public class A {
    public static void main(String args[]) {
        Scanner input = new Scanner(System.in);
        int players = input.nextInt();
        int bottles = input.nextInt();
        int towels = input.nextInt();

        int totalBottles = 0;

        while(players > 0) {
            int k = 2;
            while(k <= players) {
                k << 1;
            }
            k >> 1;

            totalBottles += k * bottles + 1;

            players -= k;
        }

        System.out.println(totalBottles + " " (towels * players));
    }
}


public class Main {
public static void main(String args[])
{
   Scanner s = new Scanner(System.in);
   String time = s.nextLine();
   SimpleDateFormat df = new SimpleDateFormat("HH:mm");

try {
	   Date d = df.parse(time);
	   Calendar cal = Calendar.getInstance();
	   cal.setTime(d);
	   cal.add(Calendar.MINUTE, s.nextInt());
	   String newTime = df.format(cal.getTime());
	   System.out.println(newTime);
} catch (ParseException e) {
	e.printStackTrace();
}
}
}


public class Solution{
    public static void main(String args[]){
        Scanner s - new Scanner(System.in);
        int hour = s.nextInt();
        int min = s.nextInt();
        int addMin = s.nextInt();

        int k = addMin/60;
        int l = addMin%60;
        for(int i = 0; i< k ; i++){
            if(hour!=24) hour += 1;
            else hour = 0;
        }

        for(int i = 0; i< l ; i++){
            if(min!=61) min += 1;
            else {
                min = 1;
                if(hour!= 24)
                    hour++;
                else
                    hour = 0;
            }
        }

        System.out.println(hour + ":" + min);
    }

}


import java.util.Scanner;

public class JavaApplication1 {

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

        String time = sc.next();
        int min = sc.nextInt();
        int hour = Integer.parseInt(time.substring(0, 2));
        int calculte_hours = (((Integer.parseInt(time.substring(3)) + min) / 60) + hour) % 24;
        int calculate_minutes = (Integer.parseInt(time.substring(3))+min) % 60;

        System.out.print(calculte_hours < 10 ?"0"+calculte_hours+":": calculte_hours+":");
        System.out.println(calculate_minutes < 10 ?"0"+calculate_minutes: calculate_minutes);

   }
}


import java.util.*;
public class TheTime {

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

    String time = kbd.nextLine();
    int add = kbd.nextInt();

	String[] value = time.split(":");

	int oldHours = Integer.parseInt(value[0]);
	int oldMinutes = Integer.parseInt(value[1]);

	int tempMinutes = oldMinutes + add; /

	if(tempMinutes > 59){
		int addHours = tempMinutes / 60;
		int addMins = tempMinutes % 60;

		int tempHours; //9
			if((oldHours+addHours) == 24)
				tempHours = 0;
			else
				tempHours = oldHours + addHours;

		int newHours = tempHours % 24;

		int newMinutes =  addMins;

		if(newHours < 10 && newMinutes < 10)
			System.out.println ("0" + newHours + ":" + "0" + newMinutes);
        else if(newHours < 10 && newMinutes >=10)
			System.out.println ("0" + newHours + ":" + newMinutes);
        else if(newHours >=10 && newMinutes >=10)
			System.out.println (newHours + ":" + newMinutes);
		else (newHours >= 10 && newMinutes < 10)
			System.out.println (newHours + ":" + "0" + newMinutes);

	}else{
		if(add == 0)
			System.out.println (value[0] + ":" + value[1]);
		else if(tempMinutes < 10)
			System.out.println (value[0] + ":0" + tempMinutes);
		else
			System.out.println (value[0] + ":" + tempMinutes);

	}

    }
}


import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class C {
    public static int n;
    public static int k;
    public static int[][] dp = new int[n+1][k+1];
    public static int[] cum = new int[n+1];
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(bf.readLine());
        int n = Integer.parseInt(st.nextToken());
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        long[][] dp = new long[n+1][k+1];
        long[][] cum = new long[n+1][k+1];
        for(int i=0; i<n+1; i++) {
            dp[i][0] = 1;
            cum[i][0] = i+1;
        }

        for(int j=1; j<k+1; j++) {
            for(int i=1; i<n+1; i++) {
                if(i == b) continue;
                if(i < b)
                    dp[i][j] = (cum[b-1][j-1]-cum[(int)Math.max(2*i-b, 0)][j-1]-dp[i][j-1] + 2*1000000007)%1000000007;
                else
                    dp[i][j] = (cum[(int)Math.max(2*i-b-1, 0)][j-1]-cum[b][j-1]-dp[i][j-1] + 2*1000000007)%1000000007;
            }
            long counter = 0;
            for(int i=0; i<n+1; i++) {
                counter += dp[i][j];
                cum[i][j] = counter % 1000000007;
            }
        }
        // for(int i=0; i<dp.length; i++) System.out.println(Arrays.toString(dp[i]));
        System.out.println(dp[a][k]);
        // Scanner scan = new Scanner(System.in);
        // PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        // int n = Integer.parseInt(bf.readLine());
        // StringTokenizer st = new StringTokenizer(bf.readLine());
        // int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        // int n = Integer.parseInt(st.nextToken());
        // int n = scan.nextInt();

        // out.close(); System.exit(0);
    }
}


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

public class Solution
{
    /* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
     static int[][] dp;
     static int n;
     static int b;
     static int mod = 1000000007;
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(br.readLine());

		 n = Integer.parseInt(st.nextToken());
		int a = Integer.parseInt(st.nextToken());
		 b = Integer.parseInt(st.nextToken());
		int k = Integer.parseInt(st.nextToken());

		dp = new int[n+1][k+1];

		if(Math.abs(a-b) == 1) out.println(0);
        else{
            int start,end = 0;
          if(a<b){
             start = 1;
             end = b-1;
             for(int i=a;i<b;i++) dp[i][0] = 1;
          }
          else{
              start = b+1;
              end = n;
              for(int i=a;i<=n;i++) dp[i][0] = 1;
          }
          out.println(solve(a,k,start,end));
        }
        		out.close();
	}

	public static int solve(int a, int k,int start,int end){
	   for(int i=1;i<=k;i++){
	       for(int j = start;j<=end;j++){
	               dp[j][i] = dp[end][i-1]-(dp[j][i-1]-dp[j-1][i-1]);
	             dp[j][i] = (dp[j][i]+dp[j-1][i])%mod;
	             }
	   }
	   return dp[end][k];
	}
}
}


xtra;

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

public class E274
{

    public static void main(String args[])
    {
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        int a=s.nextInt();
        int b=s.nextInt();
        int k=s.nextInt();
        long dp[][]=new long[2][n+1];
        long p[][]=new long[2][n+1];

        int mod=1000000007;
        for(int i=1;i<b;i++)
        {

            dp[0][i]=(Math.abs(i-b)-1+Math.min(Math.abs(i)-1, Math.abs(i-b)-1))%mod;
            p[0][i]=(p[0][i-1]+dp[0][i])%mod;
            //System.out.println(i+" "+dp[i][1]+" "+Math.abs(i-b-1)+" "+Math.min(Math.abs(i-1), Math.abs(i-b-1)));
            //System.out.println(Arrays.toString(dp[i]));
        }
        for(int i=b+1;i<=n;i++)
        {
            dp[0][i]=(Math.abs(i-b)-1+Math.max(Math.min(Math.abs(n-i), Math.abs(i-b)-1),0))%mod;
            p[0][i]=(p[0][i-1]+dp[0][i])%mod;
            //System.out.println(i+" "+dp[i][1]+" "+(Math.abs(i-b)-1)+" "+Math.min(Math.min(Math.abs(n-i)-1, Math.abs(i-b)-1),0));
            //System.out.println(Arrays.toString(dp[i]));
        }
    //  System.out.println(Arrays.toString(dp[1])+" \n"+Arrays.toString(p[1]));
        //System.out.println("------------------------------------");
        if(a<b)
        {
        for(int j=2;j<=k;j++)
        {
            for(int i=1;i<b;i++)
            {
                long tmp=0;

                tmp=p[0][b-1]-p[0][Math.max(i-Math.abs(b-i),0)];

                tmp-=dp[0][i];
                //System.out.println("trip:" +j+"pos"+i+" sum"+tmp+" start"+Math.max(i-Math.abs(b-i),0)+" end "+b+" sub"+dp[j-1][i]);
                dp[1][i]=((tmp+2*mod)%mod);
                p[1][i]=(p[1][i-1]+dp[1][i])%(long)mod;
            }
            p[0]=Arrays.copyOf(p[1],p[1].length);
            Arrays.fill(p[1],0l);
            dp[0]=Arrays.copyOf(dp[1],dp[1].length);
            Arrays.fill(dp[1],0l);
            //System.out.println(Arrays.toString(dp[j])+"\n"+Arrays.toString(p[j]));
        }
        }
        else
            if(a>b)
        {
            for(int j=2;j<=k;j++)
            {

                for(int i=b+1;i<=n;i++)
                {

                long tmp=0;
                tmp+=p[0][Math.min(i+(i-b)-1,n)];
                //tmp+=p[j-1][Math.max(Math.min(Math.abs(n-i)-1, Math.abs(i-b)-1),0)];
                tmp-=dp[0][i];

                dp[1][i]=((tmp+2*mod)%mod);

                p[1][i]=(p[1][i-1]+dp[1][i])%mod;
            }
                p[0]=Arrays.copyOf(p[1],p[1].length);
                Arrays.fill(p[1],0l);
                dp[0]=Arrays.copyOf(dp[1],dp[1].length);
                Arrays.fill(dp[1],0l);
            //System.out.println(Arrays.toString(dp[j]));
        }
        }

        System.out.println(dp[0][a]%(mod));
    }
}


public class E {
    static final int MODNUM = 1000000007;
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), a = scanner.nextInt(), b = scanner.nextInt(), k = scanner.nextInt();
        int[][] dp = new int[k + 1][], sum = new int[k + 1][];
        for (int i = 0; i < k + 1; i++) {
            dp[i] = new int[n + 1];
            sum[i] = new int[n + 1];
        }
        dp[0][a] = 1;
        for (int i = a; i <= n; i++)
            sum[0][i] = 1;

        for (int i = 1; i <= k; i++) {
            for (int j = 1; j <= n; j++) {
                if (j == b)
                    dp[i][j] = 0;
                else if (j > b) {
                    dp[i][j] = (sum[i - 1][n] - sum[i - 1][(j + b) / 2] - dp[i - 1][j]) % MODNUM;
                } else {
                    dp[i][j] = (sum[i - 1][(j + b - 1) / 2] - dp[i - 1][j]) % MODNUM;
                }

                sum[i][j] = ((sum[i][j-1] + dp[i][j]) % MODNUM + MODNUM) % MODNUM;
            }
        }

        System.out.println(sum[k][n]);
    }
}


import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x1=0,y1=0,x2=0,y2=0;
	 int x=sc.nextInt();
	 int y=sc.nextInt();
	 if(x>0 && y>0){
	     x1=0;
	     y1=x+y;
	     x2=x+y;
	     y2=0;
	 }
	 	else if(x<0 && y>0){
	     x1=x-y;
	     y1=0;
	     x2=0;
	     y2=-(x-y);
	 }

	 	else if(x<0 && y<0){
	     x1=-(-x-y);
	     y1=0;
	     x2=0;
	     y2=-(-x-y);
	 }

	 	else if(x>0 && y<0){
	     x2=x-y;
	     y2=0;
	     x1=0;
	     y1=-(x-y);
	 }
	 System.out.print(x1=" ");
	  System.out.print(y1+" ");
	   System.out.print(x2+" ");
	    System.out.print(y2+" ");
  }
}


import java.util.*;

/**
 *
 * @author greggy
 */
public class VasilyTheBearAndTriangle {
    public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int x = in.nextInt();
    int y = in.nextInt();

    int ans = Math.abs(x) + Math.abs(y);
    int xans = Integer.signum(x)*ans;
    int yans = Integer.signum(y)*ans;

    if (xans > yans) {
    int temp = xans;
    xans = yans;
    yans = temp;
    }

    System.out.println("0 "+xans+ " "+yans+ " 0");
    in.close();


import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        int x=ni();
        int y=ni();
        if(x>0 && y>0)
            pn("0 "+(x+y)+" "+(x+y)+" 0");
        if(x<0 && y>0)
            pn((x-y)+" 0 0 "+(y-x));
        if(x<0 && y<0)
            pn((x+y)+" 0 0 "+(x+y));
        if(x>0 && y<0)
            pn("0 "+(y-x)+" "+(x-y)+" 0")
    }

    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj = System.getProperty("ONLINE_JUDGE") != null;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        t=ni();
        while(t-->0) {process();}
        out.flush();out.close();
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

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

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


import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        int x=ni();
        int y=ni();
        if(x>0 && y>0)
            pn("0 "+(x+y)+" "+(x+y)+" 0");
        if(x<0 && y>0)
            pn((x-y)+" 0 0 "+(y-x));
        if(x<0 && y<0)
            pn((x+y)+" 0 0 "+(x+y));
        if(x>0 && y<0)
            pn("0 "+(y-x)+" "+(x-y)+" 0")
    }

    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj = System.getProperty("ONLINE_JUDGE") != null;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        // t=ni();
        while(t-->0) {process();}
        out.flush();out.close();
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

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

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


import java.util.*;
import java.lang.*;
public class Main{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int d = Integer.parseInt(s.charAt(6));
        if(d%2==0)System.out.print(0);
        else System.out.print(1);

    }
}


import java.util.*;
public class A
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        String=sc.next();
        if(Integer.parseInt(s.charAt(6)%2==0))
            System.out.println("0");
        else
            System.out.println("1");

    }

}


import java.util.*;
public class A
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        String=sc.next();
        if(Integer.parseInt(s.charAt(6)%2==0))
            System.out.println("0");
        else
            System.out.println("1")

    }

}


public class solution
{
    public static void main(String arg[])
    {
        Scanner in = new Scanner(System.in);
        String s = in. nextLine();
        if(s.charAt(s.length()-1) % 2==0)
            System.out. println("0");
        else
            System.out. println("1");

    }
}


import java.util.*;
public class susbus{
   public static void main(String[] args){
      Scanner sc =new Scanner(System.in);
      int n= sc.nextInt();
      System.out.println(powerthree(n,1000003);
   }
   public static int powerthree(int n,int mod){
      //3^n-1
      if(n==1) return 1;
      return 3*powerthree(n-1,mod)%mod;

   }
}


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

import static java.lang.Math.*;

public class A {

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

	final int mod = (int)1e6 + 3;

	long func(int n) {
		if(n <= 1) return 1;
		return 3 * func(n-1) % mod;
	}

	private void solve() throws Exception {
		int n = nextInt();
		out.printf("%d\n", func(n));
	}

	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer tokenizer;

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

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

	private long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	private double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	private String nextLine() throws IOException {
		return new String(in.readLine());
	}

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


import java.util.*;

public class Main {
    public static int pow(int base, int exp, int mod) {
        if (exp == 0)
            return 1 % mod ;
        else
            return (base * pow(base, exp - 1, mod)) % mod;
    }

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

        int size = in.nextInt();
        System.out.println(((size==0)?1:(pow(3, size - 1, (int)Math.pow(10, 6) + 3)));
    }
}


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

    public class Main{
        static class Run implements Runnable{
            //TODO parameters
            final boolean consoleIO = true;
            final String inFile = "input.txt";
            final String outFile = "output.txt";

            boolean[][] f;
            int n;

            boolean ok(int x, int y, int sz) {
                for(int j = 0; j < sz; ++j) {
                    int tx = x + j;
                    int ty = y + j;

                    if(tx >= n || ty >= n || f[ty][n-tx-1])
                        return false;
                }

                return true;
            }

            void cook(int x, int y, int sz) {
                if(ok(x, y, sz)) {
                    int c = 0;

                    for(int i = y; i < y+sz; ++i, ++c)
                        for(int j = x; j < x+sz-c; ++j)
                            f[i][n-j-1] = true;
                }
            }

            @Override
            public void run() {
                n = (int)Math.pow(2,nextInt());
                f = new boolean[n][n];

                int sz = n;
                while(sz != 1) {
                    for(int i = 0; i < n; ++i)
                        for(int j = 0; j < n; ++j)
                            cook(i, j, sz);

                    sz /=2;
                }

//              for(boolean[] b1:f) {
//                  for(boolean b:b1)
//                      print((b?1:0)+" ");
//                  print("\n");
//              }

                int c = 0;
                for(boolean[] b1:f)
                    for(boolean b:b1)
                        if(!b)
                            ++c;
                print(c);
                close();
            }
        //=========================================================================================================================
            BufferedReader in;
            PrintWriter out;
            StringTokenizer strTok;

            Run() {
                if (consoleIO) {
                    initConsoleIO();
                }
                else {
                    initFileIO();
                }
            }

            void initConsoleIO() {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(new OutputStreamWriter(System.out));
            }

            void initFileIO() {
                try {
                    in = new BufferedReader(new FileReader(inFile));
                    out = new PrintWriter(new FileWriter(outFile));
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            void close() {
                try {
                    in.close();
                    out.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

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

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

            float nextFloat() {
                return Float.parseFloat(nextToken());
            }

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

            String nextLine() {
                try {
                    return in.readLine();
                } catch (IOException e) {
                    return "__NULL";
                }
            }

            boolean hasMoreTokens() {
                return (strTok == null) || (strTok.hasMoreTokens());
            }

            String nextToken() {
                while (strTok == null || !strTok.hasMoreTokens()) {
                    String line;
                    try {
                        line = in.readLine();
                        strTok = new StringTokenizer(line);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }

                return strTok.nextToken();
            }

            void cout(Object o){
                System.out.println(o);
            }

            void print(Object o) {
                out.write(o.toString());
            }

            void println(Object o) {
                out.write(o.toString() + '\n');
            }

            void printf(String format, Object... args) {
                out.printf(format, args);
            }

            String sprintf(String format, Object... args) {
            return MessageFormat.format(format, args);
        }
        }

        static class Pair<A, B> {
            A a;
            B b;

            A f() {
                return a;
            }

            B s() {
                return b;
            }

            Pair(A a, B b) {
                this.a = a;
                this.b = b;
            }

            Pair(Pair<A, B> p) {
                a = p.f();
                b = p.s();
            }
        }

        public static void main(String[] args) throws IOException {
            Run run = new Run();
            Thread thread = new Thread(run);
            thread.run();
        }
    }


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;

public class CT14E {

	static StreamTokenizer in;
	static PrintWriter out;

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

	static String nextString() throws IOException {
		in.nextToken();
		return in.sval;
	}

	public static void main(String[] args) throws IOException {
		in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
		out = new PrintWriter(System.out);

		for (int t = nextInt(); t > 0; t--) {
			n = nextInt();
			k = nextInt();

			long ans = 0;
			for (int a = 0; a < 4; a++)
				for (int b = 0; b < 4; b++)
					if (a != b)
						ans += solve(n-2, k, k-1, a, b);

			out.println(ans);
		}

		out.flush();
	}

	static int n, k;
	static long[][][][][] memo = new long[20][11][11][4][4];
	static {
		for (long[][][][] a : memo)
			for (long[][][] b : a)
				for (long[][] c : b)
					for (long[] d : c)
						Arrays.fill(d, -1);
	}

	static long solve(int x, int q, int p, int a, int b) {
		if (x == 0) return q == 0 && p == 0 ? 1 : 0;
		if (q < 0 || p < 0) return 0;
		if (memo[x][q][p][a][b] != -1) return memo[x][q][p][a][b];

		int res = 0;
		for (int i = 0; i < 4; i++)
			if (i < a && a > b) res += solve(x-1, q-1, p, i, a);
			else if (i > a && a < b) res += solve(x-1, q, p-1, i, a);
			else if (i != a) res += solve(x-1, q, p, i, a);

		return memo[x][q][p][a][b] = res;
	}
}


import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
 * 4:41 ~
 *
 */
public class Main {

	public static void main(String[] argv) {
		FastScanner scan = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = scan.nextInt();
		int t = scan.nextInt();
		int dp[][][][] = new int[n+2][4 * 4 + 5][n+1][n+1];
		for(int i = 0; i < n; i++){
			if(i == 0){
				for(int j = 0; j < 4; j++){
					dp[i+1][j][0][0] = 1;
				}
			} else if(i == 1){
				for(int state = 0; state < 4; state++){
					for(int j = 0; j < 4; j++){
						if(state == j) continue;
						dp[i+1][state * 4 + j][0][0] += dp[i][state][0][0];
					}
				}
			} else {
				for(int state = 0; state < 16; state++){
					int first = state / 4;
					int second = state % 4;
					if(first == second) continue;
					for(int c = 0; c <= i/2; c++){
						for(int d = 0; d <= i/2; d++){
							for(int j = 0; j < 4; j++){
								if(second == j) continue;
								if(first < second){
									if(second < j){
										dp[i+1][second * 4 + j][c][d] += dp[i][state][c][d];
									} else if(second > j){
										dp[i+1][second * 4 + j][c+1][d] += dp[i][state][c][d];
									}
								} else if(first > second){
									if(second < j){
										dp[i+1][second * 4 + j][c][d+1] += dp[i][state][c][d];
									} else if(second > j){
										dp[i+1][second * 4 + j][c][d] += dp[i][state][c][d];
									}
								}
							}
						}
					}
				}
			}
		}
		/*
		for(int i = 0; i <= n+1; i++)
			for(int state = 0; state < 16; state++)
				for(int c = 0; c <= i / 2; c++)
					for(int d = 0; d <= i / 2; d++)
						System.out.println(i + ", (" + (state / 4) + "," + (state % 4) + "), " + c + "," + d + "  => " + dp[i][state][c][d]);
		*/
		int ret = 0;
		for(int state = 0; state < 16; state++){
			int first = state / 4;
			int second = state % 4;
			if(first == second) continue;
			ret += dp[n][state][t][t-1];
		}
		out.println(ret);
		out.close();
	}

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(InputStream is) {
			try {
				br = new BufferedReader(new InputStreamReader(is));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

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

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

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

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


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

public class Camels {
    static Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System. in )));

    static int n, t, wise[][][][][];
    static boolean done[][][][][];
    public static void main(String[] args) {
        n = in .nextInt();
        t = in .nextInt();
        wise = new int[n][t + 1][t][4][4];
        done = new boolean[n][t + 1][t][4][4];
        int ans = 0;
        for (int i = 0; i < 4; i++)
            for (int j = 0; j < i; j++) ans += remember(1, 0, 0, i, j);
        System.out.println(ans);
    }

    static int remember(int x, int h, int v, int y, int yprev) {
        if (done[x][h][v][y][yprev]) return wise[x][h][v][y][yprev];
        int ans = 0;
        if (x == n - 2) {
            if (v == t - 1) {
                for (int ynext = 0; ynext < y; ynext++) {
                    if (ynext < y && yprev < y) a{
                        if (h < t) ans++;
                    } else {
                        if (h == t) ans++;
                    }
                }
            }
        } else {
            for (int ynext = 0; ynext < 4; ynext++)
                if (ynext != y) {
                    if (ynext < y && yprev < y) {
                        if (h < t) ans += remember(x + 1, h + 1, v, ynext, y);
                    } else if (ynext > y && yprev > y) {
                        if (v < t - 1) ans += remember(x + 1, h, v + 1, ynext, y);
                    } else ans += remember(x + 1, h, v, ynext, y);
                }
        }
        done[x][h][v][y][yprev] = true;
        return wise[x][h][v][y][yprev] = ans;
    }
}


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

public class E {
    static int n;
    static int t;
    static int[][][][][] visited;
    public static int work(int index , int humps , int prev , int now  , int bel) {
        //System.out.println(s + "    "+humps + "     " + bel);
        if(index == n-1) {
            if(humps == t  && bel == t-1) {
                //System.out.println(s + "    "+humps + "     " + bel + "   hi");
                return 1;
            }
            else return 0;
        }
        if(bel >t-1 || humps >t)
            return 0;

        if(visited[index][humps][prev][now][bel] !=-1) {

            return visited[index][humps][prev][now][bel];
        }

        int result = 0;

        for(int i = 1 ; i<=4 ; i++) {
            if(now == i)
                continue;
            result += work(index +1 , (now>prev && now >i && prev !=0? humps+1:humps) , now , i , (now<prev && now <i && prev !=0? bel+1:bel));
        }
        return visited[index][humps][prev][now][bel] = result;

    }
    public static void main(String[] args) throws Exception {
        parsee in = new parsee(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int k = (int)in.nextLong();
        int[][] dp = new int[21][11];

        /*dp[3][1]=14;
        dp[3][2]=0;
        dp[3][3]=0;
        dp[3][4]=0;
        dp[3][5]=0;
        dp[3][6]=0;
        dp[3][7]=0;
        dp[3][8]=0;
        dp[3][9]=0;
        dp[3][10]=0;
        dp[4][1]=22;
        dp[4][2]=0;
        dp[4][3]=0;
        dp[4][4]=0;
        dp[4][5]=0;
        dp[4][6]=0;
        dp[4][7]=0;
        dp[4][8]=0;
        dp[4][9]=0;
        dp[4][10]=0;
        dp[5][1]=16;
        dp[5][2]=70;
        dp[5][3]=0;
        dp[5][4]=0;
        dp[5][5]=0;
        dp[5][6]=0;
        dp[5][7]=0;
        dp[5][8]=0;
        dp[5][9]=0;
        dp[5][10]=0;
        dp[6][1]=6;
        dp[6][2]=232;
        dp[6][3]=0;
        dp[6][4]=0;
        dp[6][5]=0;
        dp[6][6]=0;
        dp[6][7]=0;
        dp[6][8]=0;
        dp[6][9]=0;
        dp[6][10]=0;
        dp[7][1]=1;
        dp[7][2]=380;
        dp[7][3]=353;
        dp[7][4]=0;
        dp[7][5]=0;
        dp[7][6]=0;
        dp[7][7]=0;
        dp[7][8]=0;
        dp[7][9]=0;
        dp[7][10]=0;
        dp[8][1]=0;
        dp[8][2]=396;
        dp[8][3]=1786;
        dp[8][4]=0;
        dp[8][5]=0;
        dp[8][6]=0;
        dp[8][7]=0;
        dp[8][8]=0;
        dp[8][9]=0;
        dp[8][10]=0;
        dp[9][1]=0;
        dp[9][2]=284;
        dp[9][3]=4500;
        dp[9][4]=1782;
        dp[9][5]=0;
        dp[9][6]=0;
        dp[9][7]=0;
        dp[9][8]=0;
        dp[9][9]=0;
        dp[9][10]=0;
        dp[10][1]=0;
        dp[10][2]=142;
        dp[10][3]=7414;
        dp[10][4]=12122;
        dp[10][5]=0;
        dp[10][6]=0;
        dp[10][7]=0;
        dp[10][8]=0;
        dp[10][9]=0;
        dp[10][10]=0;
        dp[11][1]=0;
        dp[11][2]=48;
        dp[11][3]=8849;
        dp[11][4]=41160;
        dp[11][5]=8997;
        dp[11][6]=0;
        dp[11][7]=0;
        dp[11][8]=0;
        dp[11][9]=0;
        dp[11][10]=0;
        dp[12][1]=0;
        dp[12][2]=10;
        dp[12][3]=8028;
        dp[12][4]=92226;
        dp[12][5]=76878;
        dp[12][6]=0;
        dp[12][7]=0;
        dp[12][8]=0;
        dp[12][9]=0;
        dp[12][10]=0;
        dp[13][1]=0;
        dp[13][2]=1;
        dp[13][3]=5658;
        dp[13][4]=152140;
        dp[13][5]=328222;
        dp[13][6]=45425;
        dp[13][7]=0;
        dp[13][8]=0;
        dp[13][9]=0;
        dp[13][10]=0;
        dp[14][1]=0;
        dp[14][2]=0;
        dp[14][3]=3112;
        dp[14][4]=195420;
        dp[14][5]=928494;
        dp[14][6]=467292;
        dp[14][7]=0;
        dp[14][8]=0;
        dp[14][9]=0;
        dp[14][10]=0;
        dp[15][1]=0;
        dp[15][2]=0;
        dp[15][3]=1322;
        dp[15][4]=201744;
        dp[15][5]=1947581;
        dp[15][6]=2402980;
        dp[15][7]=229347;
        dp[15][8]=0;
        dp[15][9]=0;
        dp[15][10]=0;
        dp[16][1]=0;
        dp[16][2]=0;
        dp[16][3]=422;
        dp[16][4]=170444;
        dp[16][5]=3213988;
        dp[16][6]=8205152;
        dp[16][7]=2758896;
        dp[16][8]=0;
        dp[16][9]=0;
        dp[16][10]=0;
        dp[17][1]=0;
        dp[17][2]=0;
        dp[17][3]=96;
        dp[17][4]=118912;
        dp[17][5]=4322956;
        dp[17][6]=20852648;
        dp[17][7]=16594160;
        dp[17][8]=1157954;
        dp[17][9]=0;
        dp[17][10]=0;
        dp[18][1]=0;
        dp[18][2]=0;
        dp[18][3]=14;
        dp[18][4]=68640;
        dp[18][5]=4846524;
        dp[18][6]=41920210;
        dp[18][7]=66357900;
        dp[18][8]=15946870;
        dp[18][9]=0;
        dp[18][10]=0;
        dp[19][1]=0;
        dp[19][2]=0;
        dp[19][3]=1;
        dp[19][4]=32632;
        dp[19][5]=4594423;
        dp[19][6]=69183464;
        dp[19][7]=197939352;
        dp[19][8]=109824208;
        dp[19][9]=5846414;
        dp[19][10]=0;
        dp[20][1]=0;
        dp[20][2]=0;
        dp[20][3]=0;
        dp[20][4]=12628;
        dp[20][5]=3715462;
        dp[20][6]=96046590;
        dp[20][7]=468541040;
        dp[20][8]=503245466;
        dp[20][9]=90700276;
        dp[20][10]=0;*/

        for(int tt = 0 ; tt<k; tt++) {
            n = (int)in.nextLong();
            t = (int)in.nextLong();
            visited = new int[n][t+1][5][5][t];
            for(int i = 0 ; i<visited.length ; i++) {
                for(int j = 0 ; j<visited[i].length ; j++) {
                    for(int kk = 0 ; kk<visited[i][j].length ; kk++) {
                        for(int l = 0 ; l<visited[i][j][kk].length ; l++)
                            Arrays.fill(visited[i][j][kk][l], -1);
                    }
                }
            }
            int res = work(0 , 0 , 0 , 1 ,0);

            res += work(0 , 0 , 0 , 2 , 0);

            res += work(0 , 0 , 0 , 3,0);

            res += work(0 , 0 , 0 , 4 , 0);
            out.println(res);

        }
        out.flush();
    }
}