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

	        int x,y,k,i;

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

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

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

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

	    }

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

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

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

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

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

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

	        return gcd;
	    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

}


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

public class A0017 {

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

    A0017() throws Exception {
        PandaScanner sc = null;
        PrintWriter out = null;
        try {
            sc = new PandaScanner(System.in);
            out = new PrintWriter(System.out);
        } catch (Exception ignored) {
        }

        int n = sc.nextInt();

        boolean[] notPrime = new boolean[n + 1];
        for (int i = 2; i <= n; i++) {
            if (notPrime[i]) {
                continue;
            }
            for (int j = i * i; j <= n; j += i) {
                notPrime[j] = true;
            }
        }

        boolean[] covered = new boolean[n + 1];
        Cover: for (int i = 2; i <= n;) {
            for (int j = i + 1; j <= n; j++) {
                if (i + j >= n) {
                    break Cover;
                }
                if (!notPrime[j]) {
                    covered[i + j + 1] = true;
                    i = j;
                    break;
                }
            }
        }

        int k = 0;
        for (int i = 2; i <= n; i++) {
            if (!notPrime[i] && covered[i]) {
                k++;
            }
        }
        if (k >= sc.nextInt()) {
            out.println("YES");
        }
        else {
            out.println("NO");
        }

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

    //The PandaScanner class, for Panda fast scanning!
    public class PandaScanner {
        BufferedReader br;
        StringTokenizer st;
        InputStream in;

        PandaScanner(InputStream in) throws Exception {
            br = new BufferedReader(new InputStreamReader(this.in = in));
        }

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

        public boolean hasNext() throws Exception {
            return (st != null && st.hasMoreTokens()) || in.available() > 0;
        }

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

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


import java.util.Scanner;

public class BowWow {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long n = Long.parseLong(in.next(), 2);
		long ans =0;
		for(long i=0;i<n;i++) {
			if(Math.pow(4, i)<n)
				ans++;
		}
		System.out.println(ans);
	}

}


import java.util.*;
import java.math.*;
public class MyClass {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int ulet = scan.nextInt();
        int result = 0;
        for(int x = 2 ; x<=ulet; x++){
            int counter = 0;
            for(int y=2; y<x; y++){
                BigInteger prime = BigInteger.valueOf(y);
                if(prime.isProbablePrime(7)){
                    if(x%y == 0){
                        counter++;
                    }
                }
                if(counter > 2)
                    break;
            }
            if(counter == 2)
                result++;
        }
        System.out.print(result);
    }
}


public class JumpingJack {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
final int x=Math.abs(s.nextInt());

int n=0;
int p=0;
while(p < x)  {
  n++;
  p+=n;
}
if( p-x > 0 ) {
while( (p-x)%2==1 ) {
n++;
p+=n;
}
}
System.out.println(n);
}
}


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

public class Round11ProblemB {

	public static void main(String[] args) {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		try {
			int[] param = parseIntegers(input.readLine());
			int to = param[0];
			int currentStep = solve(to);
			System.out.println(currentStep);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				input.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

	private static int solve(int to) {
		int currentStep = 1;
		int[] choices = new int[] { 0 };
		while (true) {
			for (int from : choices) {
				if (from == to) {
					return currentStep - 1;
				}
				if (from + currentStep == to || from - currentStep == to) {
					return currentStep;
				}
			}
			int[] newChoices = new int[choices.length * 2];
			int i = 0;
			for (int from : choices) {
				newChoices[i++] = from + currentStep;
				newChoices[i++] = from - currentStep;
			}
			choices = newChoices;
			currentStep++;
		}
	}

	public static int[] parseIntegers(String line) {
		String[] strings = line.split("\\s");
		int[] numbers = new int[strings.length];
		for (int i = 0; i < strings.length; i++) {
			numbers[i] = Integer.parseInt(strings[i]);
		}
		return numbers;
	}
}


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

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

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

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

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

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

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

        long nextLong() {

            return Long.parseLong(next());
        }

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

    public static void main(String[] args) {
        FastReader sc= new FastReader();
        int n = sc.nextInt();
        int c = sc.nextInt();
        int[] arr = new int[n];
        for(int i=0;i<n;arr[i++]=sc.nextInt());
        int profit = 0;
        for(int i=1;i<n;i++){
            if(arr[i-1]>arr[i]){
                profit= Integer.max(profit,(arr[i-1]-arr[i]));
            }
        }
        System.out.println(profit-c);
    }
}


import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String in=bf.readLine();
        int len=in.length();
        int c=0;
        for (int i = 0; i <len/2 ; i++) {
            if (in.charAt(i)!=in.charAt(len-i-1))c++;
        }
        PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        pw.write(((c==1)?"YES":"NO")+"\n");
        pw.flush(); }}


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

import static java.lang.Math.*;

public class solver implements Runnable {

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

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

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

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    int[] readIntArr(int n, boolean sort) throws IOException {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = readInt();
        }
        if (sort)
            Arrays.sort(a);
        return a;
    }

    int[] readIntArr(int n) throws IOException {
        return readIntArr(n, false);
    }

    public static void main(String[] args) {
        new Thread(null, new solver(), "", 256 * (1L << 20)).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            init();
            solve();
            out.close();
            time();
        } catch (Exception e) {
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    final int mod = (int) 1e8;

    int sum(int a, int b) {
        return (a + b) % mod;
    }

    void solve() throws IOException {
        int n1 = readInt();
        int n2 = readInt();
        int k1 = readInt();
        int k2 = readInt();
        int[][][][][] dp = new int[n1 + n2 + 1][n1 + 1][n2 + 1][k1 + 1][k2 + 1];
        dp[0][n1][n2][0][0] = 1;

        for (int i = 1; i < n1 + n2 + 1; i++) {
            for (int c1 = n1; c1 >= 0; c1--) {
                int c2 = n1 + n2 - c1 + 1 - i;
                if (c2 < 0 || c2 > n2)
                    continue;
                for (int j = 0; j <= k1; j++) {
                    if (c1 > 0 && j < k1)
                        dp[i][c1 - 1][c2][j + 1][0] = sum(dp[i][c1 - 1][c2][j + 1][0], dp[i - 1][c1][c2][j][0]);
                    if (c2 > 0 && j > 0)
                        dp[i][c1][c2 - 1][0][1] = sum(dp[i][c1][c2 - 1][0][1], dp[i - 1][c1][c2][j][0]);

                }

                for (int j = 0; j <= k2; j++) {
                    if (c2 > 0 && j < k2)
                        dp[i][c1][c2 - 1][0][j + 1] =sum(dp[i][c1][c2 - 1][0][j + 1], dp[i - 1][c1][c2][0][j]);
                    if (c1 > 0 && j > 0)
                        dp[i][c1-1][c2][1][0] = sum(dp[i][c1-1][c2][1][0], dp[i - 1][c1][c2][0][j]);
                }
            }
        }
        int ans = 0;

        for (int i=0;i<=k1;i++) {
            ans+= dp[n1+n2][0][0][i][0];
            ans %= mod;
        }
        for (int i=0;i<=k2;i++) {
            ans+= dp[n1+n2][0][0][0][i];
            ans %= mod;
        }
        out.println(ans);

    }
}


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

public class CaesarsLegions
{
	private static int n1,n2,k1,k2;
	private static int memo[][][][][];
	public static void main(String[] args)
	{
		BufferedTokenizer io = new BufferedTokenizer(System.in);
		n1 = io.nextInt();
		n2 = io.nextInt();
		k1 = io.nextInt();
		k2 = io.nextInt();
		memo = new int[n1+n2+1][n1+1][n2+1][k1+1][k2+1];
		for (int i = 0; i < n1+n2+1; i++)
		{
			for (int j = 0; j < n1+1; j++)
			{
				for (int k = 0; k < n2+1; k++)
				{
					for (int s = 0; s < k1+1; s++)
					{
						Arrays.fill(memo[i][j][k][s], -1);
					}
				}
			}
		}
		io.println(solve(0,n1,n2,0,0)%100000000+"");
	}

	private static int solve(int place, int footMenLeft, int ridersLeft,int countFoot, int countRider)
	{
		if(countFoot>k1 || countRider>k2)	return 0;
		else if(footMenLeft==0 && ridersLeft==0)	return 1;
		else if(place==n1+n2)	return 0;
		else if(memo[place][footMenLeft][ridersLeft][countFoot][countRider]!=-1) return memo[place][footMenLeft][ridersLeft][countFoot][countRider];
		if(ridersLeft==0)
			return memo[place][footMenLeft][ridersLeft][countFoot][countRider] = solve(place+1,footMenLeft-1,0,countFoot+1,0);
		else if(footMenLeft==0)
			return memo[place][footMenLeft][ridersLeft][countFoot][countRider] = solve(place+1,0,ridersLeft-1,0,countRider+1);
		else
		 return memo[place][footMenLeft][ridersLeft][countFoot][countRider] = solve(place+1,footMenLeft-1,ridersLeft,countFoot+1,0) +
				 					solve(place+1,footMenLeft,ridersLeft-1,0,countRider+1);
	}

	public static class BufferedTokenizer
	 {
	        private BufferedReader reader;
	        private StringTokenizer tokenizer;
	        private PrintWriter writer;

	        public BufferedTokenizer(InputStream stream)
	        {
	            reader = new BufferedReader(new InputStreamReader(stream));
	            writer = new PrintWriter(System.out);
	            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 void println(String x)
	        {
	        	writer.println(x);
	        	writer.flush();
	        }
	    }

}


//package CFFEB24;

import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader;

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

public class Q2{

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

        public InputReader() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(System.in), 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 char nextChar() {
            return next().charAt(0);
        }

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

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

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

    public static void main(String[] args) {

        InputReader in = new InputReader();
        int T = in.nextInt();
        int ans[]=new int[T];

        for (int i = 0; i < T; i++){
            ans[i]=in.nextInt();
        }

        Arrays.sort(ans);
        long ans1=0;
        int j=0;

        for(int o=0;o<T-1;o++){

            if(ans[o]==0){
                continue;
            }
            if(o==0) {
                ans1++;
                continue;
            }
            if(ans[o+1]==ans[j]){
                continue;
            }
            j=o;
            ans1++;
        }

        System.out.println(ans1);

    }
}


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

public class Main {

    public static void main(String[] args) throws IOException {
        FastScanner sc=new FastScanner(System.in);
        HashSet <Integer>s=new HashSet();
        int n=sc.nextInt();
        for(int i=0;i<n;i++){
            int x=sc.nextInt();
            if (x!=0)s.add(x);
        }
        System.out.println(s.size());

    }
    static class FastScanner {
	    BufferedReader br;
	    StringTokenizer st;
            public FastScanner(InputStream i) {
	        br =  new BufferedReader(new InputStreamReader(i));
	        st = new StringTokenizer("");
	    }
	    public String next() throws IOException {
	        if(st.hasMoreTokens())return st.nextToken();
                else st = new StringTokenizer(br.readLine());
	        return next();
	    }
	    public int nextInt() throws IOException {return Integer.parseInt(next());}
	    public long nextLong() throws IOException {return Long.parseLong(next());}
	    public double nextDouble() throws IOException {return Double.parseDouble(next());}
	}
}q


package javaapplication3;

import java.util.Scanner;

public class JavaApplication3 {

    public static void main(String[] args) {
         Scanner in=new Scanner(System.in);
     long n,a,b,c,k,m;
     a=in.nextLong();
     b=in.nextLong();

    if (a*b%2==0) m=a*b/2; else m=(a*b+1)/2;
    if ((a==1)||(b==1)) m=a*b;
    if ((a==2)&(b==2)) m=4;
    if(((a==2)&(b%2==1))||((b==2)&(a%2==1))) m=(a*b+2)/2;
    if(((a==2)&(b%4==2))||((b==2)&(a%4==2))) m=(a*b+4)/2;
     System.out.println(m);
    }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int z=scan.nextInt();
        int ar=2010;
        int arM=2100;
        if(z==1){
            System.out.println(scan.nextInt());
        }
        for(int i=0; i<z-1; i++){
            int buff=scan.nextInt();
            if(ar<buff)
                ar=buff;
            if(arM>buff)
                arM=buff;
        }

        System.out.println((ar+arM)/2);

        	// write your code here
    }

}


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

/**
 * Created by Scruel on 2017/4/24.
 * Personal blog : http://blog.csdn.net/scruelt
 * Github : https://github.com/scruel
 */
public class CF769A {
        public static void main(String[] args) throws IOException {
                BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
                int n = new Integer(bfr.readLine());
                int[] years = new int[n];
                String[] rts = bfr.readLine().split("\\s+");
                for (int i = 0; i < rts.length; i++) {
                        years[i] = new Integer(rts[i]);
                }
                int year = 2010;

                for (int i = 0; i < n; i++) {
                        int distance = -1;
                        boolean flag = true;
                        year = years[i];
                        for (int j = 0; j < n; j++) {
                                if (j == i) continue;
                                if (distance == -1)
                                        distance = Math.abs(years[j] - years[i]);
                                if (Math.abs(years[j] - years[i]) != distance) {
                                        flag = false;
                                        break;
                                }
                        }
                        if (flag)
                                break;
                }
                System.out.println(year);

        }
}


package create;

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

public class TaskB {
    boolean inside(double x1, double y1, double x2, double y2, double x, double y){
         return (x>x1 && x<x2 && y<y1 && y>y2);
    }
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        //ArrayList<node> lis=new ArrayList<node>();
        double a=in.nextInt();
        double x=in.nextInt();
        double y=in.nextInt();

        int ubi=-1;

        if(inside(-a/2,a,a/2.,0,x,y))
            ubi=1;

        double xf=-a/2;
        double yf= a;
        int rank=2;
        for(int i=0;;i++){
            if(ubi!=-1)break;
            if(yf>y)break;
           if(i%2==0){
               xf=-a/2;
               yf+=a;

               if(inside(xf,yf,(xf)+a,yf-a,x,y))
                   ubi=rank;
               rank++;
           }else{
               xf=-a;
               yf+=a;

               if(inside(xf,yf,0,yf-a,x,y))
                   ubi=rank;
               if(inside(0,yf,0,yf-a,x,y))
                   ubi=rank+1;

               rank+=2;
           }
        }
        out.println(ubi);

    }

}


import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.io.InputStream;

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

class TaskB {
    boolean inside(double x1, double y1, double x2, double y2, double x, double y){
         return (x>x1 && x<x2 && y<y1 && y>y2);
    }
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        ArrayList<node> lis=new ArrayList<node>();
        double a=in.nextInt();
        double x=in.nextInt();
        double y=in.nextInt();
        lis.add(new node(-a/2.0,a,a/2.0,0));
        double xf=-a/2;
        double yf= a;
        for(int i=0;i<2000000;i++){
           if(i%2==0){
               xf=-a/2;
               yf+=a;
               lis.add(new node(xf,yf,(xf)+a,yf-a));
           }else{
               xf=-a;
               yf+=a;
               lis.add(new node(xf,yf,0,yf-a));
               lis.add(new node(0,yf,a,yf-a));
           }
        }
        int ubi=-1;
        for(int i=0;i<lis.size();i++){
            node p=lis.get(i);
            //System.out.println(p.x1+","+p.y1+" "+p.x2+","+p.y2);
           if(inside(p.x1,p.y1,p.x2,p.y2,x,y)){
               ubi=i+1;
               break;
           }

        }
        out.println(ubi);

    }

    public  class node{
        double x1,y1,x2,y2;
        public  node(){}

        public node(double x1,double y1, double x2, double y2){
            this.x1=x1;
            this.y1=y1;
            this.x2=x2;
            this.y2=y2;
        }

    }
}


import java.util.Scanner;
public class Main{
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    // ab c de
    int a = n/10000;
    int b = n/1000 - a*10;
    int c = (n%1000)/100;
    int d = (n%100)/10;
    int e = n%10;
    int a1 = a;
    int b1 = c;
    int c1 = e;
    int d1 = d;
    int e1 = b;
    int n1 =a1*10000 + b1*1000 + c1*100 + d1*10 + e1;
    long z2 = (1L*n1*n1)%100000;
    long z3 = (z2*n1)%100000;
    long z4 = (z3*n1)%100000;
    long z5 = (z4*n1)%100000;
    for (int k=1;z5*k<10000;k*=10){
        System.out.println(0);
    }
    System.out.println(z5);
  }
}


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

public class Solution {

	public static void main(String args[]){

		try{
			//FileInputStream fs = new FileInputStream(new File("input.txt"));
			//BufferedReader br = new BufferedReader(new InputStreamReader(fs));
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			//String temp[] = br.readLine();

			String temp[] = br.readLine().split(" ");
			int n = Integer.parseInt(temp[0]);
			int val[][][] = new int [n+1][4][4];
			for(int i = 1; i<=n;i++){
				for(int j = 0; j<4;j++){
					//System.out.println();
					for(int k = 0; k<4;k++){
						int value = 0;
						if (i ==1){
							if(j==k){
								val[i][j][k] = 0;
							}
							else val[i][j][k] = 1;

							}
						else{

						for(int p = 0; p<4;p++){

							if(k==p)continue;
							else{
								value = (value + val[i-1][j][p])%1000000007;
							}
							}
						val[i][j][k] = value;
						}

						}

					}

				}

			System.out.println(val[n][3][3]);
		}catch(Exception e){e.printStackTrace();}
	}
}


/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
public class Omparator implements Comparator<Integer>{

            // Overriding compare()method of Comparator
                        // for descending order of cgpa
            public int compare(Integer s1, Integer s2) {
                if (s1< s2)
                    return 1;
                else if (s1 > s2)
                    return -1;
                                return 0;
                }
        }
public class Solution {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		int[] su = new int[n];
		for(int i=0;i<n;++i){
		    a[i] = sc.nextInt();
		}
		int count = 0;
		int sum = 0;
		int temp =0;
		int k =0 ;
		su[0] = a[0];
		for(int i=1;i<n;++i){
		    su[i]=su[i-1]+a[i];
		}
		PriorityQueue<Integer> pq = new PriorityQueue<>(new Omparator());
		for(int i =0;i<n;++i){
		    count = 0;
		    if(su[i]>m && i!=0  ){
		        pq = new PriorityQueue<>(new Omparator());
		        temp = i;
		        for(int j = 0;j<temp;++j){
		            pq.add(a[j]);
		        }
		        while(su[i]>m && !pq.isEmpty()){
		            k = pq.remove();
		            su[i] = su[i] - k;

		            count++;
		        }
		        System.out.print(count+" ");
		    }else{
		        System.out.print("0 ");
		    }
		}
	}
}


import java.util.Scanner;

public class Robot {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x1=sc.nextInt();
		int y1=sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		int Dx=x2-x1;
		int Dy=y2-y1;
		int xi=0,yi=0;
		while(x1!=x2){
			if(x1<x2){x1++;xi++;}
			else{x1--;xi++;}
		}
		while(y1!=y2){
			if(y1<y2){y1++;yi++;}
			else{y1--;yi++;}
		}
		System.out.println(Math.max(xi, yi));
	}
}


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

public class A
{

	static StringBuilder st = new StringBuilder();

	static int [][][] memo ;
	static char [] s ;

	static int dp(int l , int r , int cnt)
	{
		if(l > r) return 0 ;

		if(memo[l][r][cnt] != -1)return memo[l][r][cnt] ;

		int ans  = dp(l + 1, r, 0) + 1 ;

		for(int i = l + 1 ; i <= r ; i++)
			if(s[l] == s[i])
				ans = Math.min(ans, dp(l + 1, i - 1, 0) + dp(i , r , cnt + 1 ));

		return memo[l][r][cnt] = ans ;
	}

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

		int n = sc.nextInt() ;
		s = sc.next().toCharArray() ;
		memo = new int [n][n][n] ;

		for(int i = 0 ; i< n ; i++)
			for(int j = 0 ; j < n ; j++)
				Arrays.fill(memo[i][j], -1);

		out.println(dp(0, n - 1, 0));
		out.flush();
		out.close();
	}

	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;

		Scanner(InputStream in)
		{
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

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

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

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

	}

	static void shuffle(int[] a)
	{
		int n = a.length;
		for (int i = 0; i < n; i++)
		{
			int r = i + (int) (Math.random() * (n - i));
			int tmp = a[i];
			a[i] = a[r];
			a[r] = tmp;
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.BitSet;
import java.util.LinkedList;
import java.util.Queue;

public class C {
    public static void main(String[] args) throws IOException {
        try (BufferedReader bf = new BufferedReader(new InputStreamReader(System.in))) {
            char[] n = bf.readLine().toCharArray();
            System.out.println(findSquare(n));
        }
    }

    private static boolean isSqr(int n) {
        double sqrt = Math.sqrt(n);
        long round = Math.round(sqrt);
        return Math.abs(round - sqrt) < 0.000001;
    }

    private static int findSquare(char[] ns) {
        BitSet visited = new BitSet();
        Queue<Pair> numbers = new LinkedList<>();
        numbers.add(new Pair(ns, 0));
        visited.set(toInt(ns));

        while (!numbers.isEmpty()) {
            Pair p = numbers.poll();
            char[] number = p.number;
            if (isSqr(toInt(number))) {
                return p.depth;
            }
            for (int i = 0; i < number.length; ++i) {
                if (canRemove(number, i)) {
                    char[] nextNumber = remove(number, i);
                    int nn = toInt(nextNumber);
                    if (!visited.get(nn)) {
                        if (isSqr(nn)) {
                            return p.depth + 1;
                        }
                        numbers.add(new Pair(nextNumber, p.depth + 1));
                        visited.set(nn);
                    }
                }
            }
        }
        return -1;
    }

    private static int toInt(char[] ns) {
        return Integer.parseInt(new String(ns));
    }

    private static class Pair {
        final char[] number;
        final int depth;

        private Pair(char[] number, int depth) {
            this.number = number;
            this.depth = depth;
        }
    }

    private static char[] remove(char[] ns, int k) {
        char[] newn = new char[ns.length - 1];
        for (int i = 0; i < k; ++i) {
            newn[i] = ns[i];
        }
        for (int i = k + 1; i < ns.length; ++i) {
            newn[i - 1] = ns[i];
        }
        return newn;
    }

    private static boolean canRemove(char[] ns, int i) {
        return ns.length > 1 && (i + 1 >= ns.length || ns[i + 1] != '0');
    }
}


import java.io.*;

public class CF506E {

    final static int MOD = 10007;

    static int[][] mul(int[][] a, int[][] b) {
        int[][] c = new int[a.length][a.length];
        for (int i = 0; i < a.length; ++i) {
            for (int j = 0; j < a.length; ++j) {
                for (int k = 0; k < a.length; ++k) {
                    c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % MOD;
                }
            }
        }
        return c;
    }

    static int[][] pow(int[][] a, long pow) {
        int[][] r = new int[a.length][a.length];
        for (int i = 0; i < a.length; ++i) {
            r[i][i] = 1;
        }
        while (pow > 0) {
            if (pow % 2 == 1) {
                r = mul(r, a);
            }
            pow /= 2;
            a = mul(a, a);
        }
        return r;
    }

    public static void solve(Input in, PrintWriter out) throws IOException {
        String s = in.next();
        int n = s.length();
        int k = n + in.nextInt();
        int[][][][] d = new int[n + 1][n + 1][n + 1][n + 1];
        d[0][n][0][0] = 1;
        for (int len = n; len > 0; --len) {
            for (int i = 0; i + len <= n; ++i) {
                for (int u = 0; u <= n; ++u) {
                    for (int v = 0; v <= n; ++v) {
                        if (d[i][i + len][u][v] != 0) {
                            if (s.charAt(i) == s.charAt(i + len - 1)) {
                                d[i + 1][i + len - 1][u + 1][v] = (d[i + 1][i + len - 1][u + 1][v] + d[i][i + len][u][v]) % MOD;
                            } else {
                                d[i + 1][i + len][u][v + 1] = (d[i + 1][i + len][u][v + 1] + d[i][i + len][u][v]) % MOD;
                                d[i][i + len - 1][u][v + 1] = (d[i][i + len - 1][u][v + 1] + d[i][i + len][u][v]) % MOD;
                            }
                        }
                    }
                }
            }
        }
        int[][] d1 = new int[n + 1][n + 1];
        int[][] d2 = new int[n + 1][n + 1];
        for (int i = 0; i < n; ++i) {
            for (int u = 0; u <= n; ++u) {
                for (int v = 0; v <= n; ++v) {
                    d1[u][v] += d[i][i][u][v];
                    d2[u][v] += d[i][i + 1][u][v];
                }
            }
        }
        int ans = 0;
        for (int u = 0; u <= n; ++u) {
            for (int v = 0; v <= n; ++v) {
                if (d1[u][v] != 0) { // aa
                    int states = u + v + 1;
                    int[][] a = new int[states][states];
                    for (int i = 0; i < u; ++i) {
                        a[i][i] = 25;
                        a[i][i + 1] = 1;
                    }
                    for (int i = u; i < u + v; ++i) {
                        a[i][i] = 24;
                        a[i][i + 1] = 1;
                    }
                    a = pow(a, (k - 1) / 2);
                    int cur = a[0][states - 1];
                    if (k % 2 == 1) {
                        cur = cur * 26 % MOD;
                    }
                    ans = (ans + d1[u][v] * cur) % MOD;
//                    System.err.println("d1: " + u + " " + v + " " + d1[u][v] + " " + cur);
                }
                if (d2[u][v] != 0) { // a
                    int states = u + v + 2;
                    int[][] a = new int[states][states];
                    for (int i = 0; i < u; ++i) {
                        a[i][i] = 25;
                        a[i][i + 1] = 1;
                    }
                    for (int i = u; i < u + v; ++i) {
                        a[i][i] = 24;
                        a[i][i + 1] = 1;
                    }
                    a[u + v][u + v] = 25;
                    a[u + v][u + v + 1] = 1;
//                    System.err.println(Arrays.deepToString(a));
                    a = pow(a, (k + 1) / 2);
                    int cur = a[0][states - 1];
                    ans = (ans + d2[u][v] * cur) % MOD;
//                    System.err.println("d2: " + u + " " + v + " " + d2[u][v] + " " + cur);
                }
            }
        }
        out.println(ans);
    }

    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        solve(new Input(new BufferedReader(new InputStreamReader(System.in))), out);
        out.close();
    }

    static class Input {
        BufferedReader in;
        StringBuilder sb = new StringBuilder();

        public Input(BufferedReader in) {
            this.in = in;
        }

        public Input(String s) {
            this.in = new BufferedReader(new StringReader(s));
        }

        public String next() throws IOException {
            sb.setLength(0);
            while (true) {
                int c = in.read();
                if (c == -1) {
                    return null;
                }
                if (" \n\r\t".indexOf(c) == -1) {
                    sb.append((char)c);
                    break;
                }
            }
            while (true) {
                int c = in.read();
                if (c == -1 || " \n\r\t".indexOf(c) != -1) {
                    break;
                }
                sb.append((char)c);
            }
            return sb.toString();
        }

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

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

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


import java.util.Arrays;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Random;
import java.util.HashMap;
import java.io.BufferedReader;
import java.util.Map;
import java.io.PrintStream;
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);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskE {
    static final int MODULO = 10007;
    int magic;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        String s = in.next();
        int n = in.nextInt() + s.length();
        int[][][] ways = new int[s.length()][s.length() + 1][s.length() / 2 + 2];
        int[][] waysAll = new int[3][s.length() / 2 + 1];
        ways[0][s.length()][0] = 1;
        for (int start = 0; start < s.length(); ++start)
            for (int len = s.length() - start; len >= 1; --len) {
                int[] src = ways[start][len];
                if (s.charAt(start) == s.charAt(start + len - 1)) {
                    int nlen = len - 2;
                    int[] dest;
                    if (nlen <= 0) {
                        dest = waysAll[len];
                    } else {
                        dest = ways[start + 1][nlen];
                    }
                    for (int doubles = 0; doubles < src.length; ++doubles) if (src[doubles] != 0) {
                        dest[doubles + 1] = (dest[doubles + 1] + src[doubles]) % MODULO;
                    }
                } else {
                    int nlen = len - 1;
                    int[] dest = ways[start][nlen];
                    for (int doubles = 0; doubles < src.length; ++doubles) if (src[doubles] != 0) {
                        dest[doubles] = (dest[doubles] + src[doubles]) % MODULO;
                    }
                    dest = ways[start + 1][nlen];
                    for (int doubles = 0; doubles < src.length; ++doubles) if (src[doubles] != 0) {
                        dest[doubles] = (dest[doubles] + src[doubles]) % MODULO;
                    }
                }
            }
        int steps = n / 2;
        int ret = 0;
        int maxSingles = s.length();
        int maxDoubles = waysAll[1].length - 1;
        int size = maxSingles + maxDoubles + maxDoubles;
        magic = maxDoubles + maxSingles;
        int[][] m = new int[size][size];
        for (int i = 0; i < maxSingles + maxDoubles + maxDoubles; ++i) {
            if (i + 1 < maxSingles + maxDoubles) m[i + 1][i] = 1;
            if (i >= maxSingles && i < maxSingles + maxDoubles) m[i + maxDoubles][i] = 1;
            m[i][i] = (i < maxSingles ? 24 : (i < maxSingles + maxDoubles ? 25 : 26));
        }
        m = pow(m, steps);
        for (int last = 1; last <= 2; ++last) {
            for (int doubles = 0; doubles < waysAll[last].length; ++doubles) {
                int w = waysAll[last][doubles];
                if (w != 0) {
                    int singles = s.length() + (last == 1 ? 1 : 0) - 2 * doubles;
                    if (n % 2 == 0) {
                        ret = (int) ((ret + (long) w * m[maxSingles + maxDoubles + doubles - 1][maxSingles - singles]) % MODULO);
                    } else {
                        ret = (int) ((ret + (long) w * m[maxSingles + maxDoubles + doubles - 1][maxSingles - singles] * 26) % MODULO);
                        if (last == 1) {
                            ret = (int) ((ret + (long) w * m[maxSingles + doubles - 1][maxSingles - singles]) % MODULO);
                        }
                    }
                }
            }
        }
        out.println(ret);
    }

    private int[][] pow(int[][] m, int k) {
        int[][] res = new int[m.length][m.length];
        for (int i = 0; i < m.length; ++i) res[i][i] = 1;
        while (k > 0) {
            System.err.println(k + " " + m.length);
            if (k % 2 != 0) {
                res = mul(m, res);
            }
            k /= 2;
            m = mul(m, m);
        }
        return res;
    }

    private final int BIG = Integer.MAX_VALUE - Integer.MAX_VALUE % MODULO;

    private int[][] mul(int[][] a, int[][] b) {
        int n = a.length;
        int[][] c = new int[n][n];
        for (int i = 0; i < c.length; ++i) {
            for (int j = 0; j < magic; ++j) {
                int s = 0;
                for (int k = 0; k < magic; ++k) {
                    s += a[i][k] * b[k][j];
                    if (s < 0)
                        s -= BIG;
                }
                if (i >= magic) {
                    int k = i;
                    s += a[i][k] * b[k][j];
                    if (s < 0)
                        s -= BIG;
                }
                c[i][j] = s % MODULO;
            }
            if (i >= magic) {
                int j = i;
                int s = 0;
                for (int k = 0; k < magic; ++k) {
                    s += a[i][k] * b[k][j];
                    if (s < 0)
                        s -= BIG;
                }
                if (i >= magic) {
                    int k = i;
                    s += a[i][k] * b[k][j];
                    if (s < 0)
                        s -= BIG;
                }
                c[i][j] = s % MODULO;
            }
        }
        return c;
    }

}

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.io.*;
import java.util.*;

public class Main {
    int mod = (int)1e9+7;
    int INF = (int)1e9;

    int[] m(int[] w, boolean[] v) {
        int n = w.length;
        int idx = -1;
        for(int i=0; i<n; i++) {
            if(!v[i]) {
                idx = i;
                break;
            }
        }
        if(idx==-1) {
            return new int[]{0, 0};
        }
        int[] a = new int[2];
        v[idx] = true;
        boolean f = true;
        for(int i=0; i<n; i++) {
            if(!v[i]) {
                v[i] = true;
                int[] x = m(w, v);
                x[0] += Math.abs(w[i]-w[idx]);
                x[1] = Math.max(x[1], Math.abs(w[i]-w[idx]));
                v[i] = false;
                if(f) {
                    a[0] = x[0];
                    a[1] = x[1];
                    f = false;
                } else {
                    if(x[0]-x[1]<a[0]-a[1]) {
                        a[0] = x[0];
                        a[1] = x[1];
                    }
                }
            }
        }
        v[idx] = false;
        return a;
    }

    void solve(BufferedReader br, PrintWriter out) throws IOException{
        int n = Integer.parseInt(br.readLine().trim());
        String[] s = br.readLine().trim().split(" ");
        int l = 2 * n;
        int[] w = new int[2*n];
        for(int i=0; i<2*n; i++) {
            w[i] = Integer.parseInt(s[i]);
        }
        Arrays.sort(w);
        int[] x = m(w, new boolean[l]);
        out.println(x[0]-x[1]);
        // int a = 0, b = 0 , m = 0;
        // for(int i=0; i<l-1; i+=2) {
        //     int x = Math.abs(w[i]-w[i+1]);
        //     m = Math.max(m, x);
        //     a += x;
        // }
        // out.println(Arrays.toString(w));
        // out.println("a: " + a + "  m: " + m);
        // a -= m;
        // out.println("a1: " + a);
        // for(int i=1; i<l-2; i+=2) {
        //     int x = Math.abs(w[i]-w[i+1]);
        //     b += x;
        // }
        // out.println("b: " + b);
        // out.println(Math.min(a, b));
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//Integer.parseInt(br.readLine().trim());
        while(t-->0) {
            new Main().solve(br, out);
        }
        br.close();
        out.close();
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public class B {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			int n = Integer.parseInt(br.readLine());

			String[] data = br.readLine().split(" ");
			List<Integer> weights = new ArrayList<Integer>();
			for (int i = 0; i < data.length; i++) {
				weights.add(Integer.parseInt(data[i]));
			}
			Collections.sort(weights);

			int res = Integer.MAX_VALUE;
			for (int i = 0; i < weights.size(); i++) {
				for (int j = i + 1; j < weights.size(); j++) {
					List<Integer> newWeights = new ArrayList<Integer>(weights);
					Integer firstToBeRemoved = newWeights.get(i);
					Integer secondToBeRemoved = newWeights.get(j);
					newWeights.remove(firstToBeRemoved);
					newWeights.remove(secondToBeRemoved);
					res = Math.min(solve((Integer[]) newWeights.toArray(new Integer[newWeights.size()])), res);
				}
			}

			System.out.println(res);
		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	public static int solve(Integer[] arr) {
		if (arr.length == 2) {
			return Math.abs(arr[0] - arr[1]);
		}
		int solve1 = solve(Arrays.copyOfRange(arr, 2, arr.length));

		Integer[] arr2 = new Integer[arr.length - 2];
		arr2[0] = arr[0];
		for (int i = 3; i < arr.length; i++) {
			arr2[i-2] = arr[i];
		}
		int solve2 = solve(arr2);
		return Math.min(solve1 + Math.abs(arr[0]-arr[1]), solve2 + Math.abs(arr[1]-arr[2]));
	}
}


import java.util.*;

public class Main {

	private static int search(long[] a, long key) {
		int lo = 0, hi = a.length - 1;
		while(lo < hi) {
			int mid = (lo + hi)/2;
			if(a[mid] > key)
				hi = mid - 1;
			else if(a[mid] < key)
				lo = mid + 1;
			else return mid;
		}
		return lo;
	}
	@SuppressWarnings("resource")
	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		long n = in.nextLong();
		if(n % 3 != 0)
			System.out.println(0);
		else {
			int count = 0, size = 0;
			n = n/3;
			Vector<Long> vc = new Vector<Long>();
			for(long x = 2; x * x <= n; x++) {
				if(n % x == 0) {
					vc.addElement(x);
					size++;
				}
			}
			long[] a = new long[size];
			for(int i = 0; i < size; i++) {
				a[i] = vc.elementAt(i);
			}
			long thres = (long) Math.pow(n, 1.0/3);
			int m = search(a, thres);
			for(int i = 0; i <= m; i++) {
				long x = a[i];
				long t = n / x;
				int k = search(a, (long) Math.pow(t, 0.5));
				for(int j = i; j <= k; j++) {
					if(t % a[j] == 0) {
						long y = a[j];
						long z = t / y;
						if(x + y > z && (x + y + z) % 2 == 0) {
							if(x == y && y == z)
								count++;
							else if(x == y || y == z)
								count += 3;
							else if( x < y && y < z)
								count += 6;
						}
					}
				}
			}
			System.out.println(count);
		}
	}

}


import java.util.Scanner;

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

        int cnt = 0;

        long iL = (long) (Math.pow(M, 1.0 / 3) + 1e-9);

        if (M % 6 == 0) {
            M /= 3;
            for (long i = 2; i <= iL; i++)
                if (M % i == 0) {
                    long M2 = M / i;
                    long jL = (long) (Math.sqrt(M2) + 1e-9);
                    for (long j = i; j <= jL; j++)
                        if (M2 % j == 0) {
                            long k = M2 / j;
                            if (k < j) break;
                            if (i + j > k && (i+j+k) % 2 == 0) {
                                if (i == j && i == k)
                                    ++cnt;
                                else if (i == j || i == k || j == k)
                                    cnt += 3;
                                else
                                    cnt += 6;
                            }
                        }
                }
        }

        System.out.println(cnt);
    }
}


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

public class a{
     static int[] count,count1,count2;
     static Node[] nodes;
     static long[] arr;
     static char[] ch,ch1;
     static int[] darr,farr;
     static Character[][] mat,mat1;
     static long x,h;
     static long maxl;
     static double dec;
     static String s;
     static long minl;
     static int mx = (int)1e9+5;
     static long mod = 998244353l;
     // static int minl = -1;
     // static long n;
     static int n,n1,n2;
     static long a;
     static long b;
     static long c;
     static long d;
     static long y,z;
     static int m;
     static long k;
     static String[] str,str1;
     static Set<Character> set,set1,set2;
     static List<Integer> list,list1,list2;
     static LinkedList<Character> ll;
     static Map<Integer,Integer> map;
     static StringBuilder sb,sb1,sb2;

     // public static boolean solve(){

     //    FastScanner sc = new FastScanner();
     //    int n = sc.nextInt();
     //    for(int i = 0 ; i <  n ; i++){
     //        int a = sc.nextInt();
     //        int b = sc.nextInt();
     //    }

     // }

     public static long solve(){

        long n = d;

        long ans =  n - (a+b-c);
        if(ans <= 0 || ans > n || c > Math.min(a,b) || )
            return -1;
        return ans;

     }

     public static void main(String[] args) {

            FastScanner sc = new FastScanner();
            // Scanner sc = new Scanner(System.in);
            // int t = sc.nextInt();
            int t = 1;
            // int l = 1;
            while(t > 0){

                a = sc.nextLong();
                b = sc.nextLong();
                c = sc.nextLong();
                d = sc.nextLong();

                // x = sc.nextLong();
                // y = sc.nextLong();

                // n = sc.nextLong();
                // n = sc.nextInt();
                // n1 = sc.nextInt();

                // m = sc.nextInt();

                // k = sc.nextLong();

                // ch = sc.next().toCharArray();
                // ch1 = sc.next().toCharArray();

                // arr = new long[n];
                // for(int i = 0 ; i < n ; i++){
                //     arr[i] = sc.nextLong();
                // }

                // darr = new int[n];
                // for(int i = 0; i < n ; i++){
                //     darr[i] = sc.nextInt();
                // }

                // farr = new int[n];
                // for(int i = 0; i < n ; i++){
                //     farr[i] = sc.nextInt();
                // }

                // mat = new Character[n][m];
                // for(int i = 0 ; i < n ; i++){
                //     String s = sc.next();
                //     for(int j = 0 ; j < m ; j++){
                //         mat[i][j] = s.charAt(j);
                //     }
                // }
                // str = new String[n];
                // for(int i = 0 ; i < n ; i++)
                //     str[i] = sc.next();

                // nodes = new Node[n];
                // for(int i = 0 ; i < n ;i++)
                //     nodes[i] = new node(sc.nextInt(),sc.nextInt());

                // System.out.println(solve()?"YES":"NO");
                 // solve();
                 System.out.println(solve());
                 t -= 1;
            }

     }

    public static int log(long n){

         if(n == 0 || n == 1)
             return 0;

         if(n == 2)
             return 1;

         double num = Math.log(n);
         double den = Math.log(2);

         if(den == 0)
             return 0;

         return (int)(num/den);
     }

    public static boolean isPrime(long n) {
    // Corner cases
        if (n <= 1)
            return false;

        if (n <= 3)
            return true;

        // This is checked so that we can skip
        // middle five numbers in below loop
        if (n%2 == 0 || n%3 == 0)
            return false;

        for (int i=5; i*i<=n; i=i+6)
            if (n%i == 0 || n%(i+2) == 0)
               return false;

        return true;
    }

     public static long gcd(long a,long b){

        if(b%a == 0)
            return a;

        return gcd(b%a,a);

     }

     // public static void swap(int i,int j){
     //     long temp = arr[j];
     //     arr[j] = arr[i];
     //     arr[i] = temp;
     // }

    static final Random random=new Random();

    static void ruffleSort(long[] a) {
        int n=a.length;//shuffle, then sort
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n);
            long temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }

    static class Node{
        Integer first;
        Integer second;
        Node(Integer f,Integer s){
            this.first = f;
            this.second = s;
        }
    }

     static class FastScanner {

                BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                StringTokenizer st=new StringTokenizer("");
                String next() {
                        while (!st.hasMoreTokens())
                                try {
                                        st=new StringTokenizer(br.readLine());
                                } catch (IOException e) {
                                        e.printStackTrace();
                                }
                        return st.nextToken();
                }

                int nextInt() {
                        return Integer.parseInt(next());
                }
                int[] readArray(int n) {
                        int[] a=new int[n];
                        for (int i=0; i<n; i++) a[i]=nextInt();
                        return a;
                }
                long nextLong() {
                        return Long.parseLong(next());
                }
        }

}


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

public class PermutationGame {

    public static void main(String[] args) {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        int n = in.nextInt(), m = in.nextInt();
        int[] l = new int[m], a = new int[n], t = new int[n + 1];
        boolean f = true;

        for (int i = 0; i < m; i++)
            l[i] = in.nextInt();

        for (int i = 0; i < m - 1; i++) {
            int diff = l[i + 1] - l[i];
            if (1 <= diff && diff < n && (t[diff - 1] == 0 || a[l[i] - 1] == diff)) {
                a[l[i] - 1] = diff;
                t[diff - 1] = 1;
            } else if (diff == 0 && (t[n - 1] == 0 || a[l[i] - 1] == n)) {
                a[l[i] - 1] = n;
                t[n - 1] = 1;
            } else if (diff < 0 && (t[((n - l[i]) + l[i + 1]) - 1] == 0 || a[l[i] - 1] == (n - l[i]) + l[i + 1])) {
                int i1 = (n - l[i]) + l[i + 1];
                a[l[i] - 1] = i1;
                t[i1 - 1] = 1;
            } else {
                f = false;
                break;
            }
        }

        if (f)
            for (int i = 0, next = 0; i < n; i++) {
            if (a[i] == 0)
                while (true) {
                    if (t[next++] == 0) {
                        a[i] = next;
                        break;
                    }

                }
                out.print(a[i] + " ");
            }else
                out.print("-1");

        out.close();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

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

    static class D491 {
        long[] dp;
        char[][] arr;
        long dp2;

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            String str = in.scanString();
            arr = new char[2][str.length()];
            arr[0] = str.toCharArray();
            arr[1] = in.scanString().toCharArray();
            dp = new long[110];
            dp2 = new long[105][105];
            for (long arr[] : dp2) {
                Arrays.fill(arr, -1);
            }
            Arrays.fill(dp, -1);
            dp[0] = 0;
            dp[1] = 0;
            dp[2] = 1;
            dp[3] = 2;
            for (int i = 4; i <= 100; i++) {
                dp[i] = Math.max(dp[i - 2] + 1, dp[i - 3] + 2);
            }
            out.println(findit(0, arr[0].length - 1));

        }

        long findit(int l, int r) {
            if (r - l + 1 < 2) return 0;
            if (dp2[l][r] != -1) return dp2[l][r];
            for (int i = l; i <= r; i++) {
                if (arr[0][i] == 'X' || arr[1][i] == 'X') {
                    if (arr[0][i] == 'X' && arr[1][i] == 'X') {
                        return findit(l, i - 1) + findit(i + 1, r);
                    } else {
                        if (arr[0][i] == 'X') {
                            return Math.max(findit(l, i - 2), findit(i + 2, r)) + 1;
                        } else {
                            return Math.max(findit(l, i - 2), findit(i + 2, r)) + 1;
                        }
                    }
                }
            }
            return dp2[l][r] = dp[r - l + 1];
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        public String scanString() {
            int c = scan();
            while (isWhiteSpace(c)) c = scan();
            StringBuilder RESULT = new StringBuilder();
            do {
                RESULT.appendCodePoint(c);
                c = scan();
            } while (!isWhiteSpace(c));
            return RESULT.toString();
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}


import java.io.*;
import java.util.ArrayList;
public class CodeFor1 {
	static void helper(long num , ArrayList<Integer> list)
	{
		if (num<=1)
		{
			list.add((int)num);
			return;
		}
		helper(num/2 , list);
		list.add((int)num%2);
		helper(num/2 , list);
	}
	public static void main(String[] args)  throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] in = br.readLine().strip().split(" ");
		long n = Long.parseLong(in[0]) ,l = Long.parseLong(in[1]) , r = Long.parseLong(in[2]);
		ArrayList<Integer> val = new ArrayList<>();
		helper(n , val);
		int res = 0;
		for (long i=l-1 ; i<r;i++)
		{
			res = res + val.get((int) i);
		}
		System.out.println(res);
	}
}


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

public class CorrectSolution {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String n1 = in.nextLine();
        String n2 = in.nextLine();

        n1 = minimize(n1);

        if (n1.equals(n2)) {
            System.out.println("OK");
        } else {
            System.out.println("WRONG_ANSWER");
        }

    }

    public static String minimize(String s) {
        char[] ar = new char[s.length()];
        for(int i=0;i<s.length();i++){
            ar[i]=s.charAt(i);
        }
        Arrays.sort(ar);
        while(ar[0]=='0'){
            for(int i=0;i<ar.length;i++){
                if(ar[i]!='0'){
                    ar[0]=ar[i];
                    ar[i]='0';
                    break;
                }
            }
        }
        return new String(ar);
    }
}


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

import static java.lang.Math.random;

/**
 * @author Don Li
 */
public class PointsLinesTitles {

    int N = (int) 1e5 + 10;
    int MOD = (int) 1e9 + 7;

    int n;
    int[][] p;
    List<Integer>[] G;

    boolean[] used = new boolean[N];
    Set<Integer> uniqueX = new HashSet<>(), uniqueY = new HashSet<>();
    long sumDegree = 0, numNode = 0;

    void solve() {
        n = in.nextInt();

        p = new int[n][2];
        for (int i = 0; i < n; i++) {
            p[i][0] = in.nextInt();
            p[i][1] = in.nextInt();
        }

        int[] x = new int[n], y = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = p[i][0];
            y[i] = p[i][1];
        }
        sort(x);
        sort(y);
        for (int i = 0; i < n; i++) {
            p[i][0] = lowerBound(x, p[i][0]);
            p[i][1] = lowerBound(y, p[i][1]);
        }

        G = new List[n];
        for (int i = 0; i < n; i++) G[i] = new ArrayList<>();

        List<Integer>[] ver = new List[n], hor = new List[n];
        for (int i = 0; i < n; i++) {
            ver[i] = new ArrayList<>();
            hor[i] = new ArrayList<>();
        }
        for (int i = 0; i < n; i++) {
            ver[p[i][0]].add(i);
            hor[p[i][1]].add(i);
        }
        for (int i = 0; i < n; i++) {
            ver[i].sort(Comparator.comparingInt(a -> p[a][1]));
            for (int j = 1; j < ver[i].size(); j++) {
                int u = ver[i].get(j - 1), v = ver[i].get(j);
                addNeighbors(u, v);
            }
            hor[i].sort(Comparator.comparingInt(a -> p[a][0]));
            for (int j = 1; j < hor[i].size(); j++) {
                int u = hor[i].get(j - 1), v = hor[i].get(j);
                addNeighbors(u, v);
            }
        }

        long ans = 1;
        for (int i = 0; i < n; i++) {
            if (!used[i]) {
                uniqueX.clear();
                uniqueY.clear();
                sumDegree = 0; numNode = 0;
                dfs(i);
                long ways = mpow(2, uniqueX.size() + uniqueY.size());
                if (sumDegree / 2 == numNode - 1) ways = (ways - 1 + MOD) % MOD;
                ans = ans * ways % MOD;
            }
        }
        out.println(ans);
    }

    void dfs(int u) {
        used[u] = true;
        uniqueX.add(p[u][0]);
        uniqueY.add(p[u][1]);
        numNode++;
        sumDegree += G[u].size();
        for (int v : G[u]) {
            if (!used[v]) dfs(v);
        }
    }

    long mpow(int a, int n) {
        long res = 1;
        while (n > 0) {
            if ((n & 1) > 0) res = res * a % MOD;
            a = a * a % MOD;
            n >>= 1;
        }
        return res;
    }

    void addNeighbors(int u, int v) {
        G[u].add(v);
        G[v].add(u);
    }

    void sort(int[] a) {
        int n = a.length;
        for (int i = 0; i < n; i++) {
            int j = (int) (i + random() * (n - i));
            int tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }
        Arrays.sort(a);
    }

    int lowerBound(int[] a, int k) {
        int lb = -1, ub = a.length;
        while (ub - lb > 1) {
            int m = (lb + ub) >> 1;
            if (a[m] >= k) ub = m;
            else lb = m;
        }
        return ub;
    }

    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new PointsLinesTitles().solve();
        out.close();
    }

    static FastScanner in;
    static PrintWriter out;

    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;

        public FastScanner(BufferedReader in) {
            this.in = in;
        }

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

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

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

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


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

/**
 * Actual solution is at the top, in class Solver
 */
final public class Main implements Runnable {
	private static String[] args;

	public static void main(String[] args) {
		Main.args = args;
		new Thread(null, new Main(), "MyRunThread", 1 << 26).start();
	}

	@Override
	public void run() {
		long time_beg = -1;
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		if (args.length > 0 && args[0].equals("outside")) {
			time_beg = System.currentTimeMillis();
			try {
				inputStream = new FileInputStream("IO/in.txt");
//				outputStream = new FileOutputStream("IO/out.txt");
			} catch (Exception e) {
				System.err.println(e);
				System.exit(1);
			}
		} else {
			try {
//				inputStream = new FileInputStream("file_name");
//				outputStream = new FileOutputStream("file_name");
			} catch (Exception e) {
				System.err.println(e);
				System.exit(1);
			}
		}

		Solver s = new Solver();
		s.in = new InputReader(inputStream);
		s.out = new OutputWriter(outputStream);
		if (args.length > 0 && args[0].equals("outside")) {
			s.debug = new DebugWriter(s.out);
		}

		s.solve();
		s.out.close();

		if (args.length > 0 && args[0].equals("outside")) {
			s.debug.close();
			System.err.printf("*** Total time: %.3f ***\n", (System.currentTimeMillis() - time_beg) / 1000.0);
		}
	}
}

final class Solver {
	InputReader in;
	OutputWriter out;
	DebugWriter debug;

	public void solve() {
		n = in.readInt();
		m = in.readInt();
		int k = in.readInt();
		dp = new long[n + 1][k + 1];
		C = combinations(n + 1, MOD);
		long[][] pow = new long[n + 1][2];
		for (int i = 0; i < n + 1; ++i)
			for (int kk = 0; kk < 2; ++kk)
				pow[i][kk] = power(C[n][i], m / n + kk, MOD);

		dp[0][0] = 1;

		for (int left = 1; left <= n; ++left)
			for (int kk = 0; kk <= k; ++kk)
				for (int i = 0; i <= Math.min(n, kk); ++i) {
					int count = (m % n >= left ? 1 : 0);
					dp[left][kk] += pow[i][count] * dp[left - 1][kk - i] % MOD;
					if (dp[left][kk] >= MOD) dp[left][kk] -= MOD;
				}

		out.printLine(dp[n][k]);

//		ArrayFiller.fill(dp, -1);
//		out.printLine(rec(n, k));
//		debug.printLine(dp);
	}

	long[][] dp;
	long[][] C;

	final long MOD = 1000_000_000 + 7;

	int m;
	int n;

	long rec(int left, int k) {
		if (dp[left][k] != -1) return dp[left][k];
		if (left == 0) {
			if (k == 0) return dp[left][k] = 1;
			else return dp[left][k] = 0;
		}

		long res = 0;

		for (int i = 0; i <= Math.min(n, k); ++i) {
			int count = m / n + (m % n >= left ? 1 : 0);
			res += power(C[n][i], count, MOD) * rec(left - 1, k - i) % MOD;
			if (res >= MOD) res -= MOD;
		}

		return dp[left][k] = res;
	}

	public final static long power(long value, long exponent, final long MOD) {
		long res = 1;
		while (exponent > 0) {
			if ((exponent & 1) == 1)
				res = (res * value) % MOD;
			exponent /= 2;
			value = (value * value) % MOD;
		}
		return res;
	}

	public final static long[][] combinations(int N, long MOD) {
		long[][] C = new long[N + 1][N + 1];

		for (int n = 0; n <= N; ++n) {
			C[n][0] = C[n][n] = 1;
			for (int k = 1; k < n; ++k) {
				C[n][k] = C[n - 1][k] + C[n - 1][k - 1];
				if (C[n][k] >= MOD) C[n][k] -= MOD;
			}
		}

		return C;
	}
}

final class InputReader {
	private boolean finished = false;

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;

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

	private 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 peek() {
		if (numChars == -1)
			return -1;
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				return -1;
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar];
	}

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

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

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

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

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

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

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

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

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

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

	public boolean isExhausted() {
		int value;
		while (isSpaceChar(value = peek()) && value != -1)
			read();
		return value == -1;
	}
}

final 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 print(Object... objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(Object... objects) {
		print(objects);
		writer.println();
	}

	public void printFormat(String format, Object... objects) {
		writer.printf(format, objects);
	}

	public void print(char[] objects) {
		writer.print(objects);
	}

	public void printLine(char[] objects) {
		writer.println(objects);
	}

	public void printLine(char[][] objects) {
		for (int i = 0; i < objects.length; ++i)
			printLine(objects[i]);
	}

	public void print(int[] objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(int[] objects) {
		print(objects);
		writer.println();
	}

	public void printLine(int[][] objects) {
		for (int i = 0; i < objects.length; ++i)
			printLine(objects[i]);
	}

	public void print(short[] objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(short[] objects) {
		print(objects);
		writer.println();
	}

	public void printLine(short[][] objects) {
		for (int i = 0; i < objects.length; ++i)
			printLine(objects[i]);
	}

	public void print(long[] objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(long[] objects) {
		print(objects);
		writer.println();
	}

	public void printLine(long[][] objects) {
		for (int i = 0; i < objects.length; ++i)
			printLine(objects[i]);
	}

	public void print(double[] objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(double[] objects) {
		print(objects);
		writer.println();
	}

	public void printLine(double[][] objects) {
		for (int i = 0; i < objects.length; ++i)
			printLine(objects[i]);
	}

	public void print(byte[] objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(byte[] objects) {
		print(objects);
		writer.println();
	}

	public void printLine(byte[][] objects) {
		for (int i = 0; i < objects.length; ++i)
			printLine(objects[i]);
	}

	public void print(boolean[] objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(boolean[] objects) {
		print(objects);
		writer.println();
	}

	public void printLine(boolean[][] objects) {
		for (int i = 0; i < objects.length; ++i)
			printLine(objects[i]);
	}

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

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

final class DebugWriter {
	private final OutputWriter writer;

	public DebugWriter(OutputWriter writer) {
		this.writer = writer;
	}

	private void printDebugMessage() {
		writer.print("debug:\t");
	}

	public void printLine(Object... objects) {
		flush();
		printDebugMessage();
		writer.printLine(objects);
		flush();
	}

	public void printFormat(String format, Object... objects) {
		flush();
		printDebugMessage();
		writer.printFormat(format, objects);
		flush();
	}

	public void printLine(char[] objects) {
		flush();
		printDebugMessage();
		writer.printLine(objects);
		flush();
	}

	public void printLine(char[][] objects) {
		flush();
		for (int i = 0; i < objects.length; ++i)
			printLine(objects[i]);
		flush();
	}

	public void printLine(double[] objects) {
		flush();
		printDebugMessage();
		writer.printLine(objects);
		flush();
	}

	public void printLine(double[][] objects) {
		flush();
		for (int i = 0; i < objects.length; ++i)
			printLine(objects[i]);
		flush();
	}

	public void printLine(int[] objects) {
		flush();
		printDebugMessage();
		writer.printLine(objects);
		flush();
	}

	public void printLine(int[][] objects) {
		flush();
		for (int i = 0; i < objects.length; ++i)
			printLine(objects[i]);
		flush();
	}

	public void printLine(short[] objects) {
		flush();
		printDebugMessage();
		writer.printLine(objects);
		flush();
	}

	public void printLine(short[][] objects) {
		flush();
		for (int i = 0; i < objects.length; ++i)
			printLine(objects[i]);
		flush();
	}

	public void printLine(long[] objects) {
		flush();
		printDebugMessage();
		writer.printLine(objects);
		flush();
	}

	public void printLine(long[][] objects) {
		flush();
		for (int i = 0; i < objects.length; ++i)
			printLine(objects[i]);
		flush();
	}

	public void printLine(byte[] objects) {
		flush();
		printDebugMessage();
		writer.printLine(objects);
		flush();
	}

	public void printLine(byte[][] objects) {
		flush();
		for (int i = 0; i < objects.length; ++i)
			printLine(objects[i]);
		flush();
	}

	public void printLine(boolean[] objects) {
		flush();
		printDebugMessage();
		writer.printLine(objects);
		flush();
	}

	public void printLine(boolean[][] objects) {
		flush();
		for (int i = 0; i < objects.length; ++i)
			printLine(objects[i]);
		flush();
	}

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

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

abstract class ArrayFiller {
	// fill int array
	public final static void fill(int[] array, int value) {
		for (int i = 0; i < array.length; ++i)
			array[i] = value;
	}

	public final static void fill(int[][] array, int value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(int[][][] array, int value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(int[][][][] array, int value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(int[][][][][] array, int value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(int[][][][][][] array, int value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(int[][][][][][][] array, int value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	// fill short array
	public final static void fill(short[] array, short value) {
		for (int i = 0; i < array.length; ++i)
			array[i] = value;
	}

	public final static void fill(short[][] array, short value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(short[][][] array, short value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(short[][][][] array, short value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(short[][][][][] array, short value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(short[][][][][][] array, short value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(short[][][][][][][] array, short value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	// fill long array
	public final static void fill(long[] array, long value) {
		for (int i = 0; i < array.length; ++i)
			array[i] = value;
	}

	public final static void fill(long[][] array, long value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(long[][][] array, long value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(long[][][][] array, long value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(long[][][][][] array, long value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(long[][][][][][] array, long value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(long[][][][][][][] array, long value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	// fill double array
	public final static void fill(double[] array, double value) {
		for (int i = 0; i < array.length; ++i)
			array[i] = value;
	}

	public final static void fill(double[][] array, double value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(double[][][] array, double value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(double[][][][] array, double value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(double[][][][][] array, double value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(double[][][][][][] array, double value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(double[][][][][][][] array, double value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	// fill boolean array
	public final static void fill(boolean[] array, boolean value) {
		for (int i = 0; i < array.length; ++i)
			array[i] = value;
	}

	public final static void fill(boolean[][] array, boolean value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(boolean[][][] array, boolean value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(boolean[][][][] array, boolean value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(boolean[][][][][] array, boolean value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(boolean[][][][][][] array, boolean value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(boolean[][][][][][][] array, boolean value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	// fill byte array
	public final static void fill(byte[] array, byte value) {
		for (int i = 0; i < array.length; ++i)
			array[i] = value;
	}

	public final static void fill(byte[][] array, byte value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(byte[][][] array, byte value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(byte[][][][] array, byte value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(byte[][][][][] array, byte value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(byte[][][][][][] array, byte value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(byte[][][][][][][] array, byte value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	// fill char array
	public final static void fill(char[] array, char value) {
		for (int i = 0; i < array.length; ++i)
			array[i] = value;
	}

	public final static void fill(char[][] array, char value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(char[][][] array, char value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(char[][][][] array, char value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(char[][][][][] array, char value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(char[][][][][][] array, char value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(char[][][][][][][] array, char value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	// fill String array
	public final static void fill(String[] array, String value) {
		for (int i = 0; i < array.length; ++i)
			array[i] = value;
	}

	public final static void fill(String[][] array, String value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(String[][][] array, String value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(String[][][][] array, String value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(String[][][][][] array, String value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(String[][][][][][] array, String value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}

	public final static void fill(String[][][][][][][] array, String value) {
		for (int i = 0; i < array.length; ++i)
			fill(array[i], value);
	}
}


import com.sun.org.apache.xml.internal.security.utils.XalanXPathAPI;

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

/**
 * @author gamezovladislav
 */

public class TaskD {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        Solve solve = new Solve(in, out);
        solve.solve();
        out.close();
    }

    private static class Solve {

        private final InputReader in;
        private final PrintWriter out;

        public Solve(InputReader in, PrintWriter out) {
            this.in = in;
            this.out = out;
        }

        char[][] c = new char[2][];

        public void solve() {
            c[0] = in.next().toCharArray();
            c[1] = in.next().toCharArray();
            int ans = 0;

            int n = c[0].length;

            for (int i = 0; i + 1 < n; i++) {
                int ti = type(i);
                int ti1 =  type(i+1);
                if (ti != 0 && ti1 != 0) continue;
                if (ti == 3 || ti1 == 3) continue;
                ans++;
                fill(i, ti, ti1);
            }

            out.print(ans);
        }

        private void fill(int i, int ti, int ti1) {
            if (ti == 0 && ti1 == 1) {
                c[0][i] = 'X';
                c[1][i] = 'X';
                c[0][i + 1] = 'X';
                c[1][i + 1] = c[1][i + 1];
            }
            if (ti == 0 && ti1 == 2) {
                c[0][i] = 'X';
                c[1][i] = 'X';
                c[0][i + 1] = c[0][i + 1];
                c[1][i + 1] = 'X';
            }
            if (ti == 1 && ti1 == 0) {
                c[0][i+1] = 'X';
                c[1][i+1] = 'X';
                c[0][i] = 'X';
                c[1][i] = c[1][i];
            }
            if (ti == 2 && ti1 == 0) {
                c[0][i+1] = 'X';
                c[1][i+1] = 'X';
                c[0][i] = c[0][i];
                c[1][i] = 'X';
            }
            if (ti == 0 && ti1 == 0) {
                c[0][i] = 'X';
                c[1][i] = 'X';
                c[0][i + 1] = 'X';
                c[1][i + 1] = c[1][i + 1];
            }
        }

        private int type(int i) {
            int ret = 0;
            if (c[0][i] == 'X') ret |= 1;
            if (c[1][i] == 'X') ret |= 2;
            return ret;
        }
    }

    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 double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


import java.util.Scanner;

public class SashaAndHisTrip
{
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int n, v, mod, price, i;
		n = scan.nextInt();
		v = scan.nextInt();
		mod = n- 1 - v;
		price = 0;
		i = 1;
		while (mod > 0)
		{
			price += ++i;
		}
		System.out.println(price);
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
	public static void main(String args[]) throws Exception
	{
		BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
		String time=in.readLine();
		String hrs=time.substring(0,time.indexOf(":"));
		Integer hours=Integer.parseInt(hrs);
		Integer min=Integer.parseInt(time.substring(time.indexOf(":")+1));
		while(true)
		{
			if(Integer.parseInt(((new StringBuffer(hours.toString())).reverse()).toString())<=min)
			hours++;
			if(hours>=24)
			{
				hours=0;
			}
			String hour="";
			if(hours<10)
			{
				hour+="0";
				hour+=hours;
			}
			else
			{
				hour+=hours;
			}
			int rev=Integer.parseInt(((new StringBuffer(hour)).reverse()).toString());
			if(rev<=59)
			{
				String out="";
				if(hours<10)
				{
					out+="0";
					out+=hours;

					}else
					{
						out+=hours;
					}

			if(rev<10)
			{
				out+=":0";
				out+=rev;
			}
			else
			{
				out+=":";
				out+=rev;
			}
			System.out.println(out);
			return;
			}
		}
	}
	}