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

public class Problem {

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

		new Problem().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok;
	static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
	Problem() throws FileNotFoundException{

		if (ONLINE_JUDGE) {
			in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
		} else {
			in = new BufferedReader(new FileReader("input.txt"));
			out = new PrintWriter("output.txt");
		}
		tok = new StringTokenizer("");
	}

	// ======================================================
	List<Integer>[] graph;
	int[] ans;
	boolean[] used;
	void solve() throws IOException {
		int n = rI();
		long ans = 27;
		long min = 7;
		int m = 1000*1000*1000+7;
		for(int i=0;i<n-1;++i){
			ans = (ans*27)%m;
			min = (min*7)%m;
		}
		out.println(((ans+m)-min)%m);

	}

	// ======================================================
	void run() throws IOException {
		solve();
		out.close();
	}

	char[] reverseCharArray(char[] arr){
		char[] ans = new char[arr.length];
		for(int i=0;i<arr.length;++i){
			ans[i] = arr[arr.length-i-1];
		}
		return ans;
	}
	int sqrt(double m){
		int l = 0;
		int r = 1000000000+9;
		int i=1000;
		while(r-l>1){
			int mid = (r+l)/2;
			if(mid*mid>m){
				r = mid;
			}else{
				l = mid;
			}
		}
		return l;
	}
	int countPow(int m,int n){
		int ans = 0;
		while(m%n==0&&m>0){
			ans++;
			m/=n;
		}
		return ans;
	}
	long binPow(long a, long b){
		if(b == 0){
			return 1;
		}
		if(b%2==1){
			return a*binPow(a,b-1);
		}else{
			long c = binPow(a,b/2);
			return c*c;
		}

	}
	long gcd(long a, long b){
		return b==0?a:gcd(b,a%b);
	}

	long pow(long x, long k){
		long ans=1;
		for(int i=0;i<k;++i){
			ans*=x;
		}
		return ans;
	}
	//////////////////////////////////////////////////////////////////////

	String delimiter = " ";
	String readLine() throws IOException {
		return in.readLine();
	}
	String rS() throws IOException {
		while (!tok.hasMoreTokens()) {
			String nextLine = readLine();
			if (null == nextLine)
				return null;

			tok = new StringTokenizer(nextLine);
		}

		return tok.nextToken(delimiter);
	}
	int rI() throws IOException {
		return Integer.parseInt(rS());
	}

	long rL() throws IOException {
		return Long.parseLong(rS());
	}
	int[] rA(int b) {
		int a[] = new int[b];
		for (int i = 0; i < b; i++) {
			try {
				a[i] = rI();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return a;
	}

	int[] readSortedIntArray(int size) throws IOException {
	        Integer[] array = new Integer[size];

	        for (int index = 0; index < size; ++index) {
	            array[index] = rI();
	        }
	        Arrays.sort(array);

	        int[] sortedArray = new int[size];
	        for (int index = 0; index < size; ++index) {
	            sortedArray[index] = array[index];
	        }

	        return sortedArray;
	    }

}


/*Shabeg Singh Gill*/
//code

import java .util.Scanner ;
import java.util.*;
import java.io.*;
import java.nio.IntBuffer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Iterator;
//import java.io.OutputStreamReader;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.lang.Math;
import java.io.InputStream;
import java.util.InputMismatchException;
import java.awt.Point;
import java.util.HashMap;
import java.util.Collections;
import java.util.Arrays;
//import  java.util.Collections.reverseOrder()

public class cf2{

    public static int binarysearch(int[] arr,int num){
        int n;
        n=arr.length;
        int ans;
        ans=0;
        int start;
        start=0;
        int end ;
        end=n-1;
        while(start<=end){
            int mid;
            mid=(start+end)/2;
            if (arr[mid]>num){
                end=mid-1;
            }
            else{
                ans=mid+1;
                start=mid+1;
            }
        }
        return ans;
    }

    public static void merger(int startind,int midind,int endind, ArrayList<Integer> arr){
        ArrayList<Integer> mergedSortedArray;
         mergedSortedArray= new ArrayList<Integer>();

		 int rightIndex ;
        rightIndex= midind+1;

        int leftIndex ;
        leftIndex= startind;

        while(midind>=leftIndex && endind>=rightIndex){
            if(arr.get(leftIndex)<=arr.get(rightIndex)){
                mergedSortedArray.add(arr.get(leftIndex));
                leftIndex++;
            }else{
                mergedSortedArray.add(arr.get(rightIndex));
                rightIndex++;
            }
        }
        while(midind>=leftIndex){
            mergedSortedArray.add(arr.get(leftIndex));
            leftIndex++;
        }

        while(endind>=rightIndex){
            mergedSortedArray.add(arr.get(rightIndex));
            rightIndex++;
        }

        int i ;
        i= 0;
        int j ;
        j= startind;
        while(i<mergedSortedArray.size()){
            arr.set(j, mergedSortedArray.get(i++));
            j++;
        }
    }
    public static void divide(int startIndex,int endIndex, ArrayList<Integer> arr){
        if(endIndex >startIndex&& (endIndex-startIndex)>=1){
            int mid;
            mid = (endIndex + startIndex)/2;
            divide(startIndex, mid, arr);
            divide(mid+1, endIndex, arr);
            merger(startIndex,mid,endIndex,arr);
        }
    }

    public static int gcd(int a, int b){
        return fact(Math.min(a, b));
    }
    public static int fact(int n){
        int ans =1;
        for(int i =1; i<=n; i++){
            ans=ans*i;
        }
        return ans ;
    }

    //function to find sum of array
    public static long arraysum(int[] arr, int n ){
        long sum=0;
        for(int x=0; x<n; x++){
            sum=sum+arr[x];
        }
        return sum ;
    }
    public static void main(final String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter w = new PrintWriter(outputStream);
        Scanner s =new Scanner(System.in);

        int a1=in.nextInt();
        int a2=in.nextInt();
        int a3=in.nextInt();
        int b1=in.nextInt();
        int b2=in.nextInt();
        int b3=in.nextInt();
        int n =in.nextInt();
        int sum1=a1+a2+a3;
        int sum2=b1+b2+b3;
        int count1=0;
        int count2=0;
        if(sum1%5!=0){
            count1=(sum1/5)+1;
        }
        else {
            count1=(sum1/5);
        }
        if(sum2%10!=0){
            count2=(sum2/10)+1;
        }
        else {
            count2=(sum2/10);
        }
        int ans=count1+count2;
        if(ans<=n){
            System.out.println("YES");
        }
        else {
            System.out.println("NO");
        }
    }
}

class InputReader {
    private final InputStream stream;
    private final byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.SpaceCharFilter filter;
    private final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public InputReader(final 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 (final IOException e) {
                throw new InputMismatchException();
            }

            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

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

    public int nextInt() {
        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 nextLong() {
        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 double nextDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E')
                return res * Math.pow(10, nextInt());
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }

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

        return res.toString();
    }

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

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

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


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.*;
import java.util.*;

import static java.util.stream.Collectors.*;
import static java.util.Map.Entry.*;

public class Main {

	public static void main(String[] args) throws IOException {
		FastReader in = new FastReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int m = in.nextInt();
		int f = 0;
		int c = 0;
		int x = 1;
		while (true) {
			if (x < n) {
				if (x != 1) {
					--f;
				}
				int max = m - f;
				f += max;
				c += (x * (max));
				if (x + f == n) {
					break;
				} else if (x + f > n) {
					int y = (x + f) - n;
					c -= (y * x);
					break;
				}
				++x;
			}
		}
		out.println(c);
		out.flush();
		out.close();

	}

	static class FastReader {
		StringTokenizer st;
		BufferedReader br;

		public FastReader(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public FastReader(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

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

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

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

		public long[] nextIntLong(int n) throws IOException {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextLong();
			}
			return ret;
		}

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

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

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

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

}


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

public class Solution {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int limit = (int)(Math.sqrt(n));
        if((limit + 1) * (limit + 1) == n)
            limit++;
        int result = 1;

        boolean found = false;
        for(int i = 1; i <= limit; i++){
            if(n % i == 0){
                int current = n / i;
                if(isBeautiful(current)){
                    result = current;
                    found = true;
                    break;
                }
            }
        }
        if(!found)
        for(int i = limit; i >= 1; i--){
            if(n % i == 0){
                int current = i;
                if(isBeautiful(current)){
                    result = current;
                    found = true;
                    break;
                }
            }
        }
        /*for(int i = n; i >= 2; i--){
            if(n % i == 0)
                if(isBeautiful(i)){
                result = i;
                break;
                }
        }*/
        System.out.println(result);
    }
    private static boolean isBeautiful(int n){
        boolean one = false;
        int count0 = 0;
        int count1 = 0;
        while(n > 0){
            if(one){
                if(n % 2 == 0)
                    return false;
                else {
                    count1++;
                    n /= 2;
                }
            }
            if(!one){
                if(n % 2 == 1){
                    count1++;
                    one = true;}
                else count0++;
                n /= 2;
            }
        }
        if(count0 + 1 == count1)
            return true;
        return false;
    }
}


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

public class Main {
/*

 */
	public static void main(String[] args) throws Exception {
		uu.s1();
		uu.out.close();
	}
	public static class uu {
		public static BR in = new BR();
		public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		public static boolean bg = true;
		public static void s1() throws Exception {
			long n1 = in.ni();

			IntSet s1 = new IntSet();
			for (int x = 0; x <= 9; x++){
				for (int y = x+1; y <= 9; y++){
					for (int k = 1; k <= 10; k++){
						int v1 = k;
						int[] l1 = new int[v1];
						for (;;){
							long fin = 0;
							for (int qq = 0; qq < v1; qq++){
								long cur = 0;
								if (l1[qq] == 1){
									cur = y;
								}
								else {
									cur = x;
								}
								fin*= 10l;
								fin += cur;
							}

							if (fin <= n1){
								s1.add((int)fin);
							}
							int ptr = l1.length-1;
							boolean ex = false;
							for (;;){
								if (ptr == -1){
									ex = true;
									break;
								}
								if (l1[ptr] == 0){
									l1[ptr] = 1;
									break;
								}
								else {
									l1[ptr] = 0;
									ptr--;
								}
							}
							if (ex) break;
						}
					}

				}
			}
			s1.remove(0);
			pn(s1.size);
		}

		public static void s2() throws Exception {

		}
		public static void s3() throws Exception {

		}

		private static void pn(Object... o1) {
			for (int i = 0; i < o1.length; i++){
				if (i!= 0) out.print(" ");
				out.print(o1[i]);
			}
			out.println();
		}

		public static boolean allTrue(boolean ... l1){
			for (boolean e: l1) if (!e) return false;
			return true;
		}
		public static boolean allFalse(boolean ... l1){
			for (boolean e: l1) if (e) return false;
			return true;
		}
	}
	private static class IntSet {
		public static int hash(int h) {
			h ^= (h >>> 20) ^ (h >>> 12);
			return h ^ (h >>> 7) ^ (h >>> 4);
		}

		public boolean[] used = null;
		public int[] key = null;
		public double factor = 0.7;
		public int size = 0;
		public int init = 16;
		public IntSet(){
			used  = new boolean[init];
			key = new int[init];
		}
		public void rehash(){
			int newlen = (key.length<<1)+1;
			boolean[] oldused = used;
			int[] oldkey = key;
			used = new boolean[newlen];
			key = new int[newlen];
			size = 0;
			for (int i = 0; i < oldused.length; i++){
				if (oldused[i]){
					add(oldkey[i]);
				}
			}
		}
		public int idx(int key1){
			int id = hash(key1);
			if (id < 0) id *= -1;
			id %= key.length;
			for (int i = 0; ; i++){
				int add = i*i;
				if (add < 0) add *= -1;
				id += add;
				id %= key.length;
				if (used[id]){
					if (key[id] == key1){
						return id;
					}
				}
				else {
					return id;
				}
			}
		}

		public void add(int key1){
			int id = idx(key1);
			if (!used[id]){
				used[id] = true;
				key[id] = key1;
				size++;
			}
			if (size >= factor * key.length){
				rehash();
			}
		}
		public void remove(int key1){
			int id = idx(key1);
			if (used[id]){
				used[id] = false;
				size--;
			}
		}
	}
	private static class BR {
		BufferedReader k1 = null;
		StringTokenizer k2 = null;

		public BR() {
			k1 = new BufferedReader(new InputStreamReader(System.in));
		}
		public String nx() throws Exception {
			for (;;) {
				if (k2 == null || !k2.hasMoreTokens()) {
					String temp = k1.readLine();
					if (temp == null)
						return null;
					k2 = new StringTokenizer(temp);
				}
				else
					break;
			}

			return k2.nextToken();
		}

		public int ni() throws Exception {
			return Integer.parseInt(nx());
		}
	}
}


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

public class joe{
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

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

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

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

		int nI() {
			return Integer.parseInt(n());
		}

		long nLo() {
			return Long.parseLong(n());
		}
	}

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

	public static void main(String args[]) {
		try {
			FastScanner sc = new FastScanner(System.in);
			int n = sc.nI();
			int k=sc.nI();

			int	min=(k==0||k==n)?0:1;
			int	max=(k<=n/3)?(2*k):(n-k);

			System.out.println(min+" "+max);
		} catch (Exception e) {
		}

	}
}


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

public class alicebobappleorange {
  private static InputReader in;
  private static PrintWriter out;

  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out, true);
    long x = in.nextLong(), y = in.nextLong();

    String s = get(x, y, x < y);
    if (s.equals("-")) out.println("Impossible");
    else out.println(s);
    out.close();
    System.exit(0);
  }

  public static String get(long x, long y, boolean a) {
    if (x > y) return get(y, x, a);
    if (x == 1) return (y-1)+""+(a?"B":"A");

    long c = y % x;
    if (c == 0) return "-";

    String m = get(c, x, !a);
    if (m.equals("-")) return m;
    long w = y / x;
    StringBuilder ret = new StringBuilder();
    ret.append(w);
    ret.append(a?"B":"A");
    ret.append(m);
    return ret.toString();
  }

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

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

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

    public int nextInt() {
      return Integer.parseInt(next());
    }
    public long nextLong() {
      return Long.parseLong(next());
    }
  }

}


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.StringTokenizer;

public class C {

    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 xp = nextInt();
        int yp = nextInt();
        int xv = nextInt();
        int yv = nextInt();
        if (xp <= xv && yp <= yv) {
            System.out.println("Polycarp");
        }
        else {
            int dp = xp+yp;
            int dv = Math.max(xv, yv);
            if (dp <= dv)
                System.out.println("Polycarp");
            else
                System.out.println("Vasiliy");
        }
        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.Scanner;

public class Bark{
	public static void main(String args[])
	{
		Scanner scan = new Scanner(System.in);
		String input=scan.next();
		int n=scan.nextInt();
		String[] words = new String[n];

		for(int i=0;i<n;i++){
			words[i]=scan.next();
		}for(int k=0;k<n;k++){
			for(int j=0;j<n;j++){
				String cat=words[k]+words[j];
				if(cat.contains(input)){
					System.out.println("YES");
					return;
				}
			}
		}
		System.out.println("NO");
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
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
 *
 * @author prakharjain
 */
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);
        CNewYearAndPermutation solver = new CNewYearAndPermutation();
        solver.solve(1, in, out);
        out.close();
    }

    static class CNewYearAndPermutation {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            long[] fac = factorial(n, m);
            long[] ifac = factorialInverse(n, m);

            long ans = n * fac[n];
            ans %= m;

            for (int i = 2; i <= n; i++) {
                long ca = fac[i];
                ca *= fac[n - i + 1];
                ca %= m;
                ca *= ifac[n];
                ca %= m;
                ca *= (n - i + 1);
                ca %= m;
                ca *= fac[n];
                ca %= m;

                ans += ca;
                ans %= m;
            }

            out.println(ans);
        }

        long[] factorial(int n, int mod) {
            long[] factorial = new long[n + 1];

            factorial[0] = 1;

            for (int i = 1; i <= n; i++) {
                factorial[i] = i * factorial[i - 1];
                factorial[i] %= mod;
            }

            return factorial;
        }

        long[] factorialInverse(int n, int mod) {
            long[] factorialInverse = new long[n + 1];

            long[] inv = new long[n + 1];

            inv[1] = 1;

            for (int i = 2; i <= n; i++) {
                inv[i] = inv[mod % i];
                inv[i] *= (mod - mod / i);
                inv[i] %= mod;
            }

            factorialInverse[0] = 1;

            for (int i = 1; i <= n; i++) {
                factorialInverse[i] = inv[i] * factorialInverse[i - 1];
                factorialInverse[i] %= mod;
            }

            return factorialInverse;
        }

    }

    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 println(long 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 static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        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 nextInt() {
            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 interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.util.*;

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

		int n=sc.nextInt(), m = sc.nextInt(), k = sc.nextInt();

		int left = k-1, right = n-k,ans=1;
		int temp =  0;

		m = m-n;

		while(m>=0){

			if(temp >= left && temp>=right){
				temp += m/(Math.min(temp, left)+Math.min(temp, right)+1) +1;
				break;
			}
			m-=Math.min(temp, left);
			m-=Math.min(temp, right);

			m--;
			temp++;

		}

		System.out.print(ans+temp-1);
	}
}


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

public class Solution{

	public static void print(Object line){
		System.out.print(line);
	}

	public static void println(){
		System.out.println();
	}

	public static void println(Object line){
		System.out.println(line);
	}

	public static void solve(int a){

	}

	public static void main(String args[])throws IOException{
		BufferedReader br = new BufferedReader(new
		InputStreamReader(System.in));
		int MOD = 998244353;
		int n = Integer.parseInt(br.readLine());

		// factors
		int div[] = new int[10000005];
		for(int i = 2 ; i < n+5 ; i ++ ){
			for(int j = i ; j <= n+5 ; j += i){
				div[j]++;
			}
		}

		long sum = 1;
		long res = 1;
		for (int i = 2 ; i <= n ; i ++ ){
			res = sum + div[i] + 1;
			res = res % MOD;
			sum += res;
			sum = sum % MOD;
		}
		println(res);
	}
}


import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }
    static class Solver {
        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int last = 0;
            int max = -1;
            for (int i = 0; i < n; ++i) {
                int t = in.nextInt();
                max = Math.max(max, t);
                last = t;
            }
            out.println(max ^ last);
        }

    } // wubba lubba dub dub
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreElements()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


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

/**
 * @author Andrei Chugunov
 */
public class A {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;

    void solve() throws IOException {
        int length = nextInt();
        String string = nextString();

        int cur = 0;
        StringBuilder result = new StringBuilder();
        for(int i=0; i < length; i++) {
            char c = string.charAt(i);
            if (c == '1') {
                cur++;
                continue;
            }
            if (c == '0') {
                result.append(cur);
                cur = 0;
            }

        }
        result.append(cur);

        System.out.println(result.toString());

    }

    A() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

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

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

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

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

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

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


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

public class Main {
    void solve() {
        int n=ni(),T=ni();
        int a[]=new int[2*n*n+1];
        int cnt[]=new int[301];
        for(int i=1;i<=n;i++){
            a[i]=ni();
            cnt[a[i]]++;
        }
        long start[]=new long[n*n+1];
        long end[]=new long[n*n+1];
        st=new long[4*301+1];
        if(T<=2*n){
            long ans=0;
            for(int i=n+1;i<=T*n;i++) a[i]=a[i-n];
            for(int i=1;i<=T*n;i++){

                long mx=query(1,1,a[i],1,300);
                update(1,1,300,a[i],mx+1);
                ans=Math.max(ans,mx+1);
            }
            pw.println(ans);
            return;
        }
        for(int i=n+1;i<=n*n;i++ )a[i]=a[i-n];
        for(int i=1;i<=n*n;i++){

            long mx=query(1,1,a[i],1,300);
            update(1,1,300,a[i],mx+1);
            end[i]=mx+1;
        }
        Arrays.fill(st,0);
        for(int i=n*n;i>=1;i--){

            long mx=query(1,a[i],300,1,300);
            update(1,1,300,a[i],mx+1);
            start[i]=mx+1;
        }
        long ans=0;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(a[i]<=a[j]){
                   long cc=end[n*(n-1)+i]+(T-2*n)*1L*cnt[a[i]]+start[j];

                   ans=Math.max(ans,cc);
                 //  if(ans==7543) pw.println(i+" "+j);

                }
            }
        }
        pw.println(ans);

    }
    long st[];
    void update(int id,int l,int r,int x,long val){
        if(l==r){
            st[id]=val;
        }else {
            int mid=(l+r)>>1;
            if(x<=mid) update(2*id,l,mid,x,val);
            else update(2*id+1,mid+1,r,x,val);
            st[id]=Math.max(st[2*id],st[2*id+1]);
        }
    }
    long query(int id,int x,int y,int l,int r){
        if(x>y) return 0;
        if(r<x || l>y )return 0;
        if(x<=l && r<=y) return st[id];
        int mid=(l+r)>>1;
        return Math.max(query(2*id,x,y,l,mid),query(2*id+1,x,y,mid+1,r));
    }

    long M= (long)1e9+7;
    InputStream is;
    PrintWriter pw;
    String INPUT = "";
    void run() throws Exception {
        is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        pw = new PrintWriter(System.out);
        long s = System.currentTimeMillis();
        solve();
        pw.flush();
        if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");

    }
    public static void main(String[] args) throws Exception { new Main().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();
        }
    }
    private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
    private void tr(Object... o) { if(INPUT.length() > 0)System.out.println(Arrays.deepToString(o)); }

}


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

		java.util.Scanner scan=new java.util.Scanner(System.in);
		int n=scan.nextInt();
		int k=scan.nextInt();
		long red=2*n;
		long green=5*n;
		long blue=8*n;
		if(red%k==0){
			red=red/k;
		}else{
			red=red/k+1;
		}
		if(green%k==0){
			green=green/k;
		}else{
			green=green/k+1;
		}
		if(blue%k==0){
			blue=blue/k;
		}else{
			blue=blue/k+1;
		}
		long sum=red+green+blue;
		System.out.println(sum);
	}
}


import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;
import java.io.BufferedWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.IOException;

/**
 * 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);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();
            int m = in.readInt();
            if (n == 1) {
                out.print(1);
                return;
            }
            if (m > n / 2)
                out.print(m - 1);
            else
                out.print(m + 1);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private 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 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 print(int i) {
            writer.print(i);
        }

    }
}


import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class H {

	static int k;

	private static int mult(int x, int y) {
		int m = x * y;
		int r = 0;
		int st = 1;
		while (m != 0) {
			r += (m % k) * st;
			st *= 10;
			m /= k;
		}
		return r;
	}

	/**
	 * @param args
	 * @throws FileNotFoundException
	 */
	public static void main(String[] args) throws FileNotFoundException {
//		Scanner in = new Scanner(new FileInputStream("stdin"));
//		PrintWriter out = new PrintWriter(new FileOutputStream("stdout"));
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		k = in.nextInt();
		for (int i = 1; i < k; i++) {
			for (int j = 1; j < k; j++) {
				if (j != 1) {
					out.print(' ');
				}
				out.print(mult(i, j));
			}
			out.println();
		}

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

}


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

public class Main {

    private  static void solver(InputReader sc, PrintWriter out) throws Exception {
          int n =  sc.nextInt();
          int k =  sc.nextInt();
          int arr[] = new int[n];
          for(int i=0;i<n;i++){
              arr[i]=sc.nextInt();
          }
          int count=0;
        int i=0,j=n-1;
        boolean flag1=true,flag2=true;
          for(;i<n && j>=0 && i<=j;) {
              if(i==j){
                  if(arr[i]<=k)
                      count++;
                  break;
              }
              if(!flag1 && !flag2){
                  break;
              }
              if (arr[i] <= k && flag1) {
                  count++;
                 i++;
              }else
                  flag1 = false;
              if (arr[j] <= k && flag2){
                  count++;
                j--;
              }
              else
                  flag2 = false;
          }
          out.println(count);
    }
    private  static long gcd(long a, long b){
        if(b==0)
            return a;
        else
            return gcd(b,a%b);
    }

    public static void main(String[] args) throws Exception{
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong(){
            return Long.parseLong(next());
        }

        public long[] readLongArr(int n){
            long arr[] = new long[n];
            for(int i=0; i<n; i++){
                arr[i] = nextLong();
            }
            return arr;
        }
        public int[] readIntArr(int n){
            int arr[] = new int[n];
            for(int i=0; i<n; i++){
                arr[i] = nextInt();
            }
            return arr;
        }
    }
}
class Pair implements Comparable<Pair>{
    int x;
    String s;
    Pair(int x, String s){
        this.x = x;
        this.s = s;
    }
    public int compareTo(Pair p){
        return this.x-p.x;
    }
}


import java.util.*;
public class Main
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        boolean p=true;
        int n=s.length();
        int fi=-1,li=-1,before=0,after=0;
        for(int i=0;i<n;i++)
        {
            if(fi==-1 && s.charAt(i)!='0')
            {
                fi=i;
            }
            if(s.charAt(n-1-i)!='0' && li==-1)
            {
                li=n-1-i;
            }
            if(fi!=-1 && li!=-1)
            {
                break;
            }
        }
        before=fi;
        after=n-1-li;
        if(before<=after)
        {
            for(int i=fi;i<=li;i++)
            {
                if(s.charAt(i)!=s.charAt(li-i))
                {
                    p=false;
                    break;
                }
            }
            if(p)
            {
                System.out.println("YES");
            }
            else{
                System.out.println("NO");
            }
        }
        else{
            System.out.println("NO");
        }
    }
}


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

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

	FastReader in = new FastReader();
	PrintWriter out = new PrintWriter(System.out);
	void run(){
		work();
		out.flush();
	}
	long mod=1000000007;
	long gcd(long a,long b) {
		return a==0?b:b>=a?gcd(b%a,a):gcd(b,a);
	}
	void work() {
		int a=in.nextInt(),b=in.nextInt(),k=in.nextInt(),t=in.nextInt();
		long[] dp1=new long[250000];
		long[] dp2=new long[250000];
		dp1[120000]=1;
		dp2[b-a+120000]=1;
		for(int p=0;p<t;p++) {
			long[] ndp1=new long[250000];
			long[] ndp2=new long[250000];
			for(int i=1000;i<240000;i++) {
				if(dp1[i]>0) {
					ndp1[i-k]=(ndp1[i-k]+dp1[i]+mod)%mod;
					ndp1[i+k+1]=(ndp1[i+k+1]-dp1[i]+mod)%mod;
				}
				if(dp2[i]>0) {
					ndp2[i-k]=(ndp2[i-k]+dp2[i]+mod)%mod;
					ndp2[i+k+1]=(ndp2[i+k+1]-dp2[i]+mod)%mod;
				}
			}
			for(int i=1;i<250000;i++) {
				ndp1[i]=(ndp1[i]+ndp1[i-1]+mod)%mod;
				ndp2[i]=(ndp2[i]+ndp2[i-1]+mod)%mod;
			}
			dp1=ndp1;
			dp2=ndp2;
		}
		long ret=0;
		long sum=0;
		for(int i=0;i<250000;i++) {
			ret=(ret+(dp1[i]*sum))%mod;
			sum=(sum+dp2[i])%mod;
		}
		out.println(ret);
	}
}

class FastReader
{
	BufferedReader br;
	StringTokenizer st;

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

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

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

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


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

public class CP {
    static Scanner sc = new Scanner(System.in);
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;

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

        String next()

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

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static int lowerBound
            (Integer[] array, int length, int value) {
        int l = 0;
        int r = length;
        while (l < r) {
            int mid = (l + r) / 2;
            if (value < array[mid]) {
                r = mid;
            } else {
                l = mid + 1;
            }
        }
        return l;
    }
    public static long gcd(long a, long b){
        if (b == 0)
            return a;
        else return gcd(b, a % b);
    }
    public static void swap(int x, int y ){
        int temp =y;
        y=x;
        x=temp;
    }
    public static void main(String [] args) {
         //int T = sc.nextInt();while (T--!=0)
        {
            solve();
        }
    }
    public static void solve() {
///////////////////////////////////////////////////////////////////////////////////////////
        String a =sc.next(),b=sc.next(),c=sc.next();
        Map<Character,Integer> m =new HashMap<>();
        m.put('A',0);
        m.put('B',0);
        m.put('C',0);
        if(a.charAt(1)=='>'){
            m.put(a.charAt(0),m.get(a.charAt(0))+1);
        } if(a.charAt(1)=='<'){
            m.put(a.charAt(2),m.get(a.charAt(2))+1);
        } if(b.charAt(1)=='>'){
            m.put(b.charAt(0),m.get(b.charAt(0))+1);
        } if(b.charAt(1)=='<'){
            m.put(b.charAt(2),m.get(b.charAt(2))+1);
        } if(c.charAt(1)=='>'){
            m.put(c.charAt(0),m.get(c.charAt(0))+1);
        } if(c.charAt(1)=='<'){
            m.put(c.charAt(2),m.get(c.charAt(2))+1);
        }
        if(m.get('A')==1 && m.get('B')==1 && m.get('C')==1){
            System.out.println("Impossible");
            return;
        }
       else  if(m.get('A')==0){
            System.out.print('A');
        }
       else  if(m.get('B')==0)
            System.out.print('B');
     else   if(m.get('C')==0)
            System.out.print('C');
        if(m.get('A')==1)
            System.out.print('A');
      else   if(m.get('B')==1)
            System.out.print('B');
   else      if(m.get('C')==1)
            System.out.print('C');
        if(m.get('A')==2)
            System.out.print('A');
       else if(m.get('B')==2)
            System.out.println('B');
       else if (m.get('C')==2)
            System.out.println('C');
////////////////////////////////////////////////////////////////////////////////////////////
    }

}


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

public class WizardsAndDemonstration {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int total = Integer.parseInt(st.nextToken());
		int wizards = Integer.parseInt(st.nextToken());
		double requiredPrecentage = Double.parseDouble(st.nextToken())/100;
		double needed = Math.ceil((total*requiredPrecentage));
		if (needed <= wizards)
			System.out.println(0);
		else
			System.out.println((int) (needed-wizards));
	}

}


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

public class Pro
{
    public static void main(String[] args)
    {
        Scanner cin = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int a = cin.nextInt();
        int b = cin.nextInt();
        int q = 0;
        for(int i = 0; i < 40; i++)
        {
            for(int j = 0; j < 40; j++)
            {
                long kk = 1;
                for (int x = 0; x < i; x++)
                {
                    kk = kk * 2;
                }
                for (int y = 0; y < j; y++)
                {
                    kk = kk * 3;
                    if (kk > 2000000000)
                        break;
                }
                //out.println(kk);
                if (a <= kk && kk <= b)
                    q++;
            }
        }
        out.println(q);
        out.flush();
    }
}


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

public class A {

	private static final long MOD = (long) (1e9 + 7.1);

	private void solve() throws IOException {
		int n = nextInt();
		int k = nextInt();

		long res = 0;
		int[] a = new int[k];
//		a[k - 1] = 1;

		byte[] f = new byte[k];

		if (k == 1) {
			res = 1;
		}

		while (true) {
			boolean end = true;
			for (int i = 0; i < k; i++) {
				if (a[i] < k - 1) {
					a[i]++;
					end = false;
					for (int j = 0; j < i; j++) {
						a[j] = 0;
					}
					break;
				}
			}

			if (end) {
				break;
			}

			Arrays.fill(f, (byte)0);
			byte p = 1;
			f[k - 1] = 100;
			boolean b = true;
			for (int i = 0; i < k - 1; i++) {
				if (f[i] == 0) {
					int j = i;
					do {
						f[j] = p;
						j = a[j];
					} while (f[j] == 0);

					if (f[j] == p) {
						b = false;
						break;
					}
				}

				p++;
			}

			if (b) {
				res++;
//				for (int i = 0; i < 4; i++) {
//					print(a[i] + " ");
//				}
//				println("");
			}
		}

//		System.err.println(res);

		for (int i = k; i < n; i++) {
			res = (res * (n - k)) % MOD;
		}

		println(res);
	}

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

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

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

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

	private void print(Object o) {
		writer.print(o);
	}

	private void println(Object o) {
		writer.println(o);
	}

	private void printf(String format, Object... o) {
		writer.printf(format, o);
	}

	public static void main(String[] args) {
		long time = System.currentTimeMillis();
		Locale.setDefault(Locale.US);
		new A().run();
		System.err.printf("%.3f\n", 1e-3 * (System.currentTimeMillis() - time));
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	private void run() {
		try {
			reader = new BufferedReader(new InputStreamReader(System.in));
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(13);
		}
	}
}


import java.util.Scanner;

public class Training {

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

    int a = da5el.nextInt();
        int b = da5el.nextInt();
        int sum = a+b ;
        System.out.println(sum);
    }

}


import java.util.Scanner;

public class Round1 {
public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int sum3 = a+b;
    System.out.println(sum3);
}
}


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

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println(in.nextInt()+in.nextInt());
        in.close();

    }
}


import java.util.InputMismatchException;
import java.util.Scanner;

public class First {

    public static void main(String[] args) {
    try {
        int sum = 0;
        Scanner input=new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        if (a>=0&&a<=1000&&b>=0&&b<=1000) {
        sum = a+b;
        System.out.println(sum);
        }
        else System.out.println("fail");

        //break;
        } catch (InputMismatchException ex){
            System.out.println("Input error, try again.");
        }
      }
}


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

public class Main {
//
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer stoken = new StringTokenizer(br.readLine(), " ");
        System.out.println(Integer.parseInt(stoken.nextToken()) + Integer.parseInt(stoken.nextToken()));
        System.exit(0);
    }
}


import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);

        System.out.println(sc.nextInt() + sc.nextInt());
        sc.close();
    }
}


import java.util.*;
import java.io.*;
public class APlusBBackHook
{
public static void main(String[] args)
{
PrintStream out = System.out;
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
out.println(a+b);
out.close();
}
}


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

import static java.lang.Math.*;

/**
 * @author master_j
 */
public class Solution {
    private IO io;
    private static final String _localArg = "master_j";
    private final String _problemName = "";
    private final int _inMode = IO.STD_;
    private final int _outMode = IO.STD_;
    private final boolean _autoFlush = false;

    private void solve() throws IOException {

        io.wln(io.nI() + io.nI());
    }//2.2250738585072012e-308

    private void init(boolean local) throws IOException {
        if(local)
            io = new IO(IO._PUT_TXT, IO.STD_);
        else{
            if((_inMode == IO.PROBNAME_ || _outMode == IO.PROBNAME_) && _problemName.length() == 0)
                throw new IllegalStateException("You imbecile. Where's my <_problemName>?");
            io = new IO(_inMode, _outMode);
        }

        long nanoTime = 0;
        if(local){
            nanoTime -= System.nanoTime();
            if(_autoFlush)
                io.wln("NOTE: auto-flush is on.");
            io.wln("<output>");
            io.flush();
        }

        solve();
        io.flush();

        if(local){
            io.wln("</output>");
            nanoTime += System.nanoTime();
            long d9 = 1000000000, d6 = 1000000, d3 = 1000;
            if(nanoTime >= d9)
                io.wf("%d.%d seconds\n", nanoTime/d9, nanoTime%d9);
            else if(nanoTime >= d6)
                io.wf("%d.%d millis\n", nanoTime/d6, nanoTime%d6);
            else if(nanoTime >= d3)
                io.wf("%d.%d micros\n", nanoTime/d3, nanoTime%d3);
            else
                io.wf("%d nanos\n", nanoTime);
            io.flush();
        }

        io.close();
    }

    /**
     * Input-output class
     *
     * @author master_j
     * @version 0.3.2
     */
    private class IO {
//     _____________________________ _________________
//    |  mode  |      from/to       |  variable name  |
//    |--------|--------------------|-----------------|
//    |    0   |      System.*      |       STD_      |
//    |    1   |      *put.txt      |     _PUT_TXT    |
//    |    2   |  <_problemName>.*  |     PROBNAME_   |
//    |________|____________________|_________________|
//

        static final int STD_ = 0;
        static final int _PUT_TXT = 1;
        static final int PROBNAME_ = 2;

        StreamTokenizer st;
        BufferedReader br;
        Reader reader;

        PrintWriter pw;
        Writer writer;

        IO(int inMode, int outMode) throws IOException {
            Locale.setDefault(Locale.US);

            if(inMode == IO.STD_)
                reader = new InputStreamReader(System.in);
            else if(inMode == IO._PUT_TXT)
                reader = new FileReader("input.txt");
            else if(inMode == IO.PROBNAME_)
                reader = new FileReader(_problemName + ".in");
            else
                throw new IllegalStateException("You imbecile. How did you do that?");

            if(outMode == IO.STD_)
                writer = new OutputStreamWriter(System.out);
            else if(outMode == IO._PUT_TXT)
                writer = new FileWriter("output.txt");
            else if(outMode == IO.PROBNAME_)
                writer = new FileWriter(_problemName + ".out");
            else
                throw new IllegalStateException("You imbecille. Why did you do that?");

            br = new BufferedReader(reader);
            st = new StreamTokenizer(br);

            pw = new PrintWriter(writer, _autoFlush);
        }

        void wln()          {pw.println(); }
        void wln(boolean x) {pw.println(x);}
        void wln(char x)    {pw.println(x);}
        void wln(char x[])  {pw.println(x);}
        void wln(double x)  {pw.println(x);}
        void wln(float x)   {pw.println(x);}
        void wln(int x)     {pw.println(x);}
        void wln(long x)    {pw.println(x);}
        void wln(Object x)  {pw.println(x);}
        void wln(String x)  {pw.println(x);}

        void wf(String f, Object...o){pw.printf(f, o);}

        void w(boolean x)   {pw.print(x);}
        void w(char x)      {pw.print(x);}
        void w(char x[])    {pw.print(x);}
        void w(double x)    {pw.print(x);}
        void w(float x)     {pw.print(x);}
        void w(int x)       {pw.print(x);}
        void w(long x)      {pw.print(x);}
        void w(Object x)    {pw.print(x);}
        void w(String x)    {pw.print(x);}

        int nI() throws IOException    {st.nextToken(); return (int)st.nval;}
        double nD() throws IOException {st.nextToken(); return st.nval;}
        float nF() throws IOException  {st.nextToken(); return (float)st.nval;}
        long nL() throws IOException   {st.nextToken(); return (long)st.nval;}
        String nS() throws IOException {st.nextToken(); return st.sval;}

        void wc(String x){ wc(x.toCharArray()); }
        void wc(char c1, char c2){for(char c = c1; c<=c2; c++)wc(c);}
        void wc(char x[]){
            for(char c : x)
                wc(c);
        }
        void wc(char x){st.ordinaryChar(x); st.wordChars(x, x);}

        public boolean eof() {return st.ttype == StreamTokenizer.TT_EOF;}
        public boolean eol() {return st.ttype == StreamTokenizer.TT_EOL;}

        void flush(){pw.flush();}
        void close() throws IOException{reader.close(); br.close(); flush(); pw.close();}
    }

    public static void main(final String args[]) throws IOException {
        new Solution().init(args.length == 1 && args[0].equals(_localArg));
    }
}


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

public class APlusBStrikesBack{
	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(br.readLine());
		int A=Integer.parseInt(st.nextToken());
		int B=Integer.parseInt(st.nextToken());
		System.out.println(A+B);
	}
}


import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
    static class Reader
    {
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;}
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];}
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;}
        public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();}
        public long l(){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 int i(){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 double d() throws IOException {return Double.parseDouble(s()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; }
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; }
        public int[] arr(int n){int[] ret = new int[n];for (int i = 0; i < n; i++) {ret[i] = i();}return ret;}
    }

           //       |----|       /\      |    |   -----   |
           //       |   /       /  \     |    |     |     |
           //       |--/       /----\    |----|     |     |
           //       |   \     /      \   |    |     |     |
           //       |    \   /        \  |    |   -----   -------

    static int n;
    public static void main(String[] args)throws IOException
    {
        PrintWriter out= new PrintWriter(System.out);
        Reader sc=new Reader();
        //////
        int a=sc.i();
        int b=sc.i();
        out.print(a+b);
        out.flush();
    }
}


import java.util.*;

public class main {

    public static void main(String[] args) {
      //sidenote: this question fails first 5 times and is an aprils fool joke
        Scanner s = new Scanner(System.in);
        System.out.println(s.nextInt()+s.nextInt());
    }

}


import java.util.*;
import java.math.*;
public class Test{
public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    BigInteger sum = BigInteger.valueOf(0);
    long a = sc.nextLong();
    long b = sc.nextLong();
    sum = sum.add(BigInteger.valueOf(a));
    sum = sum.add(BigInteger.valueOf(b));
    System.out.println(sum);

}
}


import java.util.Scanner;

public class Practica_2 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String a = in.nextLine();
        String ar[] = a.split(" +");
        int b = Integer.parseInt(ar[0]);
        int c = Integer.parseInt(ar[1]);
        System.out.println(b+c+"    ");
    }
}


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

public class Battee5 {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer s = new StringTokenizer(br.readLine());
		int a = new Integer(s.nextToken());
		int b = new Integer(s.nextToken());
////		int count = 0;
//		for (int i = 0; i <= a; i++) {
////			for (int j = 1; j <= b; j++) {
////				count += i;
////			}
//			b += i;
//		}
		System.out.println(a+b);

	}

}


import java.io.IOException;

public class H {

	private static final int IN_BUFFER_SIZE = 1 << 16;
	private static final int OUT_BUFFER_SIZE = 1 << 16;
	private byte[] input = new byte[IN_BUFFER_SIZE];
	private int ix = IN_BUFFER_SIZE;
	private int bytesRead = ix;
	private byte[] output = new byte[OUT_BUFFER_SIZE];
	private int ox = 0;

	private void readMore() {
		try {
			bytesRead = System.in.read(input, 0, IN_BUFFER_SIZE);
			if (bytesRead <= 0)
				throw new RuntimeException();
			ix = 0;
		} catch (IOException e) {
			throw new RuntimeException();
		}
	}

	private void flushOut() {
		System.out.write(output, 0, ox);
		ox = 0;
	}

	private void append(char c) {
		if (ox == OUT_BUFFER_SIZE)
			flushOut();
		output[ox++] = (byte) c;
	}

	private int nextInt() {
		skipSpaces();
		int ret = 0;
		if (ix == bytesRead) {
			readMore();
		}
		int sign = 1;
		if (input[ix] == '-') {
			sign = -1;
			ix++;
		}
		while (true) {
			if (ix == bytesRead) {
				try {
					readMore();
				} catch (RuntimeException e) {
					return ret;
				}
			}
			if (input[ix] < '0') {
				break;
			}
			ret *= 10;
			ret += input[ix++] - '0';
		}
		return sign * ret;
	}

	int cntSize;

	private void skipSpaces() {
		while (true) {
			if (ix == bytesRead) {
				readMore();
			}
			if (input[ix] > ' ')
				break;
			ix++;
		}
	}

	private char[] nn = new char[32];

	private void printInt(int n) {
		if (n == 0) {
			append('0');
		} else {
			if (n < 0) {
				append('-');
				n = -n;
			}
			int kk = 0;
			while (n > 0) {
				nn[kk++] = (char) (n % 10 + '0');
				n /= 10;
			}
			for (int i = kk - 1; i >= 0; i--) {
				append(nn[i]);
			}
		}
	}

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

	private void work() {
		int b = nextInt();
		int c = nextInt();
		printInt(b + c);
		append('\n');
		if (ox > 0)
			flushOut();
		System.out.close();
	}
}


//package CF;

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

public class CF_H_409 {
static int add(int x,int y){

return x+y;

}
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner in =new Scanner(System.in);
		//int A=in.nextInt();
		//int B=in.nextInt();

System.out.println(add(in.nextInt(),in.nextInt()));

	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}

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

	}
}


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

public class A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int A  = sc.nextInt();
		int B  = sc.nextInt();
		int C  = (A+B)%2000;
		out.println(C);
		out.close();
	}

	static class FasterScanner{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FasterScanner(){
			stream = System.in;
			//stream = new FileInputStream(new File("dec.in"));

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

		boolean isSpaceChar(int c){
			return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
		}
		boolean isEndline(int c){
			return c=='\n'||c=='\r'||c==-1;
		}
		int nextInt(){
			return Integer.parseInt(next());
		}
		long nextLong(){
			return Long.parseLong(next());
		}
		double nextDouble(){
			return Double.parseDouble(next());
		}
		String next(){
			int c = read();
			while(isSpaceChar(c))
				c=read();
			StringBuilder res = new StringBuilder();
			do{
				res.appendCodePoint(c);
				c=read();
			} while(!isSpaceChar(c));
			return res.toString();
		}
		String nextLine(){
			int c = read();
			while(isEndline(c))
				c=read();
			StringBuilder res = new StringBuilder();
			do{
				res.appendCodePoint(c);
				c = read();
			}while(!isEndline(c));
			return res.toString();
		}

	}

}


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

import static java.lang.Integer.parseInt;

public class A {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tk = new StringTokenizer(in.readLine());
        int a,b;
        a = parseInt(tk.nextToken());
        b = parseInt(tk.nextToken());
        System.out.println((a + b));
    }
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        new Thread(null, new Runnable() {
            public void run() {

                try {
                    long prevTime = System.currentTimeMillis();
                    new Main().run();
                    System.err.println("Total time: "
                            + (System.currentTimeMillis() - prevTime) + " ms");
                    System.err.println("Memory status: " + memoryStatus());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }, "1", 1L << 24).start();
    }

    void run() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        Object o = solve();
        if (o != null)
            out.println(o);
        out.close();
        in.close();
    }

    private Object solve() throws IOException {
        int a = ni();
        int b = ni();
        return a+b;
    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer strTok = new StringTokenizer("");

    String nextToken() throws IOException {
        while (!strTok.hasMoreTokens())
            strTok = new StringTokenizer(in.readLine());
        return strTok.nextToken();
    }

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

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

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

    int[] nia(int size) throws IOException {
        int[] ret = new int[size];
        for (int i = 0; i < size; i++)
            ret[i] = ni();
        return ret;
    }

    long[] nla(int size) throws IOException {
        long[] ret = new long[size];
        for (int i = 0; i < size; i++)
            ret[i] = nl();
        return ret;
    }

    double[] nda(int size) throws IOException {
        double[] ret = new double[size];
        for (int i = 0; i < size; i++)
            ret[i] = nd();
        return ret;
    }

    String nextLine() throws IOException {
        strTok = new StringTokenizer("");
        return in.readLine();
    }

    boolean EOF() throws IOException {
        while (!strTok.hasMoreTokens()) {
            String s = in.readLine();
            if (s == null)
                return true;
            strTok = new StringTokenizer(s);
        }
        return false;
    }

    void printRepeat(String s, int count) {
        for (int i = 0; i < count; i++)
            out.print(s);
    }

    void printArray(int[] array) {
        for (int i = 0; i < array.length; i++) {
            if (i > 0)
                out.print(' ');
            out.print(array[i]);
        }
        out.println();
    }

    void printArray(long[] array) {
        for (int i = 0; i < array.length; i++) {
            if (i > 0)
                out.print(' ');
            out.print(array[i]);
        }
        out.println();
    }

    void printArray(double[] array) {
        for (int i = 0; i < array.length; i++) {
            if (i > 0)
                out.print(' ');
            out.print(array[i]);
        }
        out.println();
    }

    void printArray(double[] array, String spec) {
        for (int i = 0; i < array.length; i++) {
            if (i > 0)
                out.print(' ');
            out.printf(Locale.US, spec, array[i]);
        }
        out.println();
    }

    void printArray(Object[] array) {
        boolean blank = false;
        for (Object x : array) {
            if (blank)
                out.print(' ');
            else
                blank = true;
            out.print(x);
        }
        out.println();
    }

    @SuppressWarnings("rawtypes")
    void printCollection(Collection collection) {
        boolean blank = false;
        for (Object x : collection) {
            if (blank)
                out.print(' ');
            else
                blank = true;
            out.print(x);
        }
        out.println();
    }

    static String memoryStatus() {
        return (Runtime.getRuntime().totalMemory()
                - Runtime.getRuntime().freeMemory() >> 20)
                + "/" + (Runtime.getRuntime().totalMemory() >> 20) + " MB";
    }

    public void pln() {
        out.println();
    }

    public void pln(int arg) {
        out.println(arg);
    }

    public void pln(long arg) {
        out.println(arg);
    }

    public void pln(double arg) {
        out.println(arg);
    }

    public void pln(String arg) {
        out.println(arg);
    }

    public void pln(boolean arg) {
        out.println(arg);
    }

    public void pln(char arg) {
        out.println(arg);
    }

    public void pln(float arg) {
        out.println(arg);
    }

    public void pln(Object arg) {
        out.println(arg);
    }

    public void p(int arg) {
        out.print(arg);
    }

    public void p(long arg) {
        out.print(arg);
    }

    public void p(double arg) {
        out.print(arg);
    }

    public void p(String arg) {
        out.print(arg);
    }

    public void p(boolean arg) {
        out.print(arg);
    }

    public void p(char arg) {
        out.print(arg);
    }

    public void p(float arg) {
        out.print(arg);
    }

    public void p(Object arg) {
        out.print(arg);
    }

}


import java.util.Scanner;

public class Sum {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int b = in.nextInt();
		int a = in.nextInt();
		System.out.println(a+b);
		in.close();
	}

}


import java.util.Scanner;

public class B {
public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 int m=sc.nextInt();
	 System.out.print(sc.nextInt()+m);
}
}


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();
		if(n <= t){
			out.println(0);
			out.close();
			return;
		}

		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.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.LinkedList;
import java.util.TreeMap;
public class Main {
	public static Scanner in=new Scanner(System.in);
	public static int num;
	public static int time[][]=new int[25][61];
	public static void main(String[] args){
		int a;
		int ta;
		int b;
		int tb;
		String s=in.nextLine();
		int z=0;
		int count=0;
		while(s.charAt(z)!=' ')z++;
		a=Integer.parseInt(s.substring(0, z));
		ta=Integer.parseInt(s.substring(z+1, s.length()));
		s=in.nextLine();
		z=0;
		while(s.charAt(z)!=' ')z++;
		b=Integer.parseInt(s.substring(0, z));
		tb=Integer.parseInt(s.substring(z+1, s.length()));
		s=in.nextLine();
		int starth=Integer.parseInt(s.substring(0, 2));
		int startm=Integer.parseInt(s.substring(3, 5));
		int hs=starth*60+startm;
		int he=hs+ta;
		int j=b;
		for(int i=300;i<24*60;i++){
			if(j==b){
				if(i>(hs-tb)&&i<he){
					count++;
				}
				j=1;
			}
			else{
				j++;
			}
		}
		System.out.println(count);
	}
}


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

public class B {
	static Set<Integer> []edges;
	static boolean ans;
	static boolean []used;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int v,u;
		used = new boolean [6];
		ans = false;
		edges = new Set[6];
		for (int i = 0; i < 6; i++) {
			edges[i] = new HashSet<Integer>();
		}
		for (int i = 0; i < m; i++) {
			v = sc.nextInt();
			u = sc.nextInt();
			edges[v].add(u);
			edges[u].add(v);
		}
		int cnt = 0;
		for (int i = 1; i <=5; i++) {
			for (int j = i+1; j <=5; j++) {
				if (!edges[i].contains(j))
				for (int k = j+1; k <=5; k++) {
					if (!edges[j].contains(k) && !edges[i].contains(k)){
						System.out.println("WIN");
						return;
					}
				}
			}
		}

		for (int i = 1; i <=5; i++) {
			if (edges[i].size() >= 3) ans = true;
		}
		if (cnt >= 2 ) ans = true;
		System.out.println(!ans?"FAIL":"WIN");
	}
}


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

public class BBi implements Runnable {
	public static void main(String[] args) {
		new Thread(new BBi()).run();
	}

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer in;
	PrintWriter out = new PrintWriter(System.out);

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

		return in.nextToken();
	}

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

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

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

	int n, x, y;

	public long count(long z) {
		long total = 0;

		long[][] c = new long[][] { { x, y }, { y, n - x + 1 },
				{ n - x + 1, n - y + 1 }, { n - y + 1, x } };

		for (int i = 0; i < c.length; i++) {
			long inside = z;

			for (int j = 0; j < c[i].length; j++) {
				if (z > c[i][j]) {
					total += Math.min(z - c[i][j], c[i][1 - j]) * c[i][j];
					inside -= (z - c[i][j]);
				}
			}

			if (z > c[i][0] && z > c[i][1]) {
				total -= Math.min(z - c[i][0], c[i][1])
						* Math.min(z - c[i][1], c[i][0]);
			}

			if (inside > 0)
				total += inside * (inside + 1) / 2;
		}

		for (int i = 0; i < c.length; i++) {
			total -= Math.min(z, c[i][0]);
		}

		return total + 1;
	}

	public long solve(int n, int x, int y, long c) throws IOException {
		this.n = n;
		this.x = x;
		this.y = y;

		long l = 0;
		long r = 2L * n + 2;
		while (r - l > 1) {
			long z = (l + r) / 2;

			if (c <= count(z)) {
				r = z;
			} else {
				l = z;
			}
		}

		return r - 1;
	}

	public void run() {
		try {
			out.println(solve(nextInt(), nextInt(), nextInt(), nextLong()));
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
}


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

public class Main{
static int mod = (int)(Math.pow(10, 9) + 7);
   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      int n=  sc.nextInt();
      long sum = 0;
      for (int i = 0; i < n; i++) {
            sum += sc.nextInt() * (i * 4);
      }
      out.println(sum);

      out.close();
   }

   static long pow(long a, long N) {
	   if (N == 0) return 1;
	   else if (N == 1) return a;
	   else {
		   long R = pow(a,N/2);
		   if (N % 2 == 0) {
			   return R*R;
		   }
		   else {
			   return R*R*a;
		   }
	   }
   }

   static long powMod(long a, long N) {
	   if (N == 0) return 1;
	   else if (N == 1) return a % mod;
	   else {
		   long R = powMod(a,N/2) % mod;
		   R *= R % mod;
		   if (N % 2 == 1) {
			   R *= a % mod;
		   }
			   return R % mod;
	   }
   }
static void mergeSort(int[] A){ // low to hi sort, single array only
      int n = A.length;
      if (n < 2) return;
      int[] l = new int[n/2];
      int[] r = new int[n - n/2];

      for (int i = 0; i < n/2; i++){
        l[i] = A[i];
      }

      for (int j = n/2; j < n; j++){
        r[j-n/2] = A[j];
      }

      mergeSort(l);
      mergeSort(r);
      merge(l, r, A);
    }

    static void merge(int[] l, int[] r, int[] a){
      int i = 0, j = 0, k = 0;
      while (i < l.length && j < r.length && k < a.length){
        if (l[i] < r[j]){
          a[k] = l[i];
          i++;
        }
        else{
          a[k] = r[j];
          j++;
        }
        k++;
      }
      while (i < l.length){
        a[k] = l[i];
        i++;
        k++;
      }

      while (j < r.length){
        a[k] = r[j];
        j++;
        k++;
      }
    }

   //-----------PrintWriter for faster output---------------------------------
   public static PrintWriter out;

   //-----------MyScanner class for faster input----------
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;

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

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

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

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

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

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

   }
   //--------------------------------------------------------
}


import java.math.BigInteger;
import java.util.Scanner;

/**
 *
 * @author AdminHP-262
 */
public class Hexagons {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        BigInteger res = (BigInteger.valueOf(n).
                multiply(BigInteger.valueOf(n + 1)))
                .multiply(BigInteger.valueOf(3)).add(BigInteger.ONE);
        System.out.println(res);
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Set;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.util.StringTokenizer;
import java.io.BufferedReader;
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;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            Point[] p = new Point[n];
            long sx = 0;
            long sy = 0;
            for (int i = 0; i < n; i++) {
                long x = in.nextLong();
                long y = in.nextLong();
                x *= n;
                y *= n;
                p[i] = new Point(x, y);
                sx += x;
                sy += y;
            }
            sx /= n;
            sy /= n;
            for (int i = 0; i < n; i++) {
                p[i].x -= sx;
                p[i].y -= sy;
            }
            p = removeSymmetrical(p);
            n = p.length;

            if (n <= 1) {
                out.println(-1);
                return;
            }

            Set<Point> ans = new TreeSet<>();
            for (int step = 0; step < 2; step++) {
                for (int i = 0; i < n; i++) {
                    Point dir = p[step == 0 ? 0 : i].add(p[i]).rotate90();
                    if (dir.x == 0 && dir.y == 0) {
                        continue;
                    }
                    dir.normalizeDirection();
                    long[] xs = new long[n];
                    for (int j = 0; j < n; j++) {
                        xs[j] = dot(dir, p[j]);
                    }
                    Arrays.sort(xs);

                    boolean ok = true;
                    for (int j = 0; j < n; j++) {
                        if (xs[0] + xs[n - 1] != xs[j] + xs[n - 1 - j]) {
                            ok = false;
                            break;
                        }
                    }
                    if (ok) {
                        ans.add(dir);
                    }
                }
            }
            out.println(ans.size());
        }

        private Point[] removeSymmetrical(Point[] p) {
            int n = p.length;
            boolean[] dead = new boolean[n];
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    if (!dead[i] && !dead[j] && p[i].x == -p[j].x && p[i].y == -p[j].y) {
                        dead[i] = true;
                        dead[j] = true;
                    }
                }
            }

            int k = 0;
            for (int i = 0; i < n; i++) {
                if (!dead[i]) {
                    p[k++] = p[i];
                }
            }
            return Arrays.copyOf(p, k);
        }

        private long dot(Point a, Point b) {
            return a.x * b.x + a.y * b.y;
        }

        private long gcd(long a, long b) {
            return b == 0 ? a : gcd(b, a % b);
        }

        class Point implements Comparable<Point> {
            long x;
            long y;

            Point(long x, long y) {
                this.x = x;
                this.y = y;
            }

            Point add(Point o) {
                return new Point(x + o.x, y + o.y);
            }

            Point rotate90() {
                return new Point(-y, x);
            }

            void normalizeDirection() {
                long d = gcd(Math.abs(x), Math.abs(y));
                if (y > 0 || y == 0 && x > 0) {

                } else {
                    x = -x;
                    y = -y;
                }
                if (d != 0) {
                    x /= d;
                    y /= d;
                }
            }

            public int compareTo(Point o) {
                if (x != o.x) {
                    return x < o.x ? -1 : 1;
                }
                if (y != o.y) {
                    return y < o.y ? -1 : 1;
                }
                return 0;
            }

        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

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

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

    }
}


import java.util.Scanner;

public class Odds {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int runs = scan.nextInt();
		int[] a = new int[runs];

		for (int i =0 ; i <runs;i++){
			a[i]= scan.nextInt();

		}
		if(runs %2==1&&a[0]%2==1&&a[a.length-1]%2==1){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}

	}

}


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

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

class TaskA {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        int cost = 0;
        for (int i = 0; i < k; i++) {
            int count1 = 0;
            int count2 = 0;
            int cur = i;
            while (cur < n) {
                if (a[cur] == 1) ++count1;
                if (a[cur] == 2) ++count2;
                cur += k;
            }
            cost += Math.min(count1, count2);
        }
        out.println(cost);
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

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

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

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

}


import java.util.*;
import static java.lang.Math.*;
public class Demo{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		String s = in.next();
		int count=0;
		for (int i = 0; i < s.length(); i++){
			if(s.charAt(i)=='+'){count++;}else{count--;}
			count = count<0? 0:count;
		}

		System.out.println(count);
	}
}