import java.util.*;
public class Solution {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int[] arr = new int[N];
        String g = in.nextInt();
        for(int i = 0; i < N; i++) {
            arr[i] = (g.charAt(i) == '+') ? 1 : -1;
        }

        int minIndex = 0;
        int min = Integer.MAX_VALUE;
        for(int i = 0; i < N; i++) {
            if(arr[i] <= min) {
                min = arr[i];
                minIndex = i;
            }
        }

        int increase = 0;
        for(int i = minIndex; i < N; i++) {
            if(arr[i] == 1) {
                increase++;
            }
            else {
                increase--;
            }
        }

        System.out.println(increase);
    }
}


package com.darkbit.problems;

import net.egork.io.InputReader;
import net.egork.io.OutputWriter;

public class D2RemoveTheSubstringHardVersion {
  public void solve(int testNumber, InputReader in, OutputWriter out) {

    String s = in.readString();
    String t = in.readString();
    int n = s.length();
    int m = t.length();
    int[] left = new int[t.length() + 5];
    int[] right = new int[t.length() + 5];

    int j = 0;
    for (int i = 0; j < t.length(); ++i)
      if (s.charAt(i) == t.charAt(j)) {
        left[j++] = i;
      }
    j = t.length() - 1;
    for (int i = s.length() - 1; j >= 0; --i)
      if (s.charAt(i) == t.charAt(j)) {
        right[j--] = i;
      }

    int ans = Math.max(right[0], n - left[m - 1] - 1);

    for (int i = 0; i + 1 < m; i++) ans = Math.max(ans, right[i + 1] - left[i] - 1);
    for (int i = 0; i + 1 < m; i++) ans = Math.max(ans, left[i + 1] - left[i] - 1);
    for (int i = 0; i + 1 < m; i++) ans = Math.max(ans, right[i + 1] - right[i] - 1);

    out.printLine(ans);
  }
}


import java.util.*;

public class imBored {
    public static void main(String [] args);
    int a1 = Scanner.nextInt();
    int b1 =  Scanner.nextInt();

    int smaller;

    if(a1 > b1){
        smaller = b1;
    }
    else{
        smaller = a1;
    }

    int ans = 1;
    for(int i = 1; i <= smaller; i++){
        ans = ans*i;
    }
    System.out.println(ans);
}


import java.util.Scanner;

public class regex {

	static Scanner scanner = new Scanner(System.in);
	static int x1, y1, x2, y2;

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

		x1 = scanner.nextInt();
		y1 = scanner.nextInt();

		x2 = scanner.nextInt();
		y2 = scanner.nextInt();

		int d = 0;

		x2 = x2 + x1 * -1;
		y2 = y2 + y1 * -1;

		x2 = Math.abs(x2);
		y2 = Math.abs(y2);

		int min = Math.min(x2, y2);

		d += min;
		d += Math.abs(x2 - y2);

		System.out.println(d);

	}

}


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

public class Round157B {
	public static void main(String[] args) throws IOException {
		rd = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(System.out);
		M = Integer.parseInt(rd.readLine());
		for(int i=0; i<C.length; i++) C[i][0] = 1;
		for(int i=1; i<C.length; i++) for(int j=1; j<=i; j++) C[i][j] = (C[i-1][j] + C[i-1][j-1])%P;
		p2[0] = p8[0] = 1;
		for(int i=1; i<20; i++){
			p2[i] = (p2[i-1] * 2)%P;
			p8[i] = (p8[i-1] * 8)%P;
		}
		countNArray();
		long ans = 0;
		for(int NL=0; NL<=9; NL++){
			for(int x1=0; x1<=9; x1++){
				for(int x2=0; x2<=9; x2++){
					for(int x3=0; x3<=9; x3++){
						for(int x4=0; x4<=9; x4++){
							for(int x5=0; x5<=9; x5++){
								for(int x6=0; x6<=Math.min(9, NL-x1-x2-x3-x4-x5-1); x6++){
									ans += countFor(NL, x1, x2, x3, x4, x5, x6);
									if(ans>P) ans -= P;
								}
							}
						}
					}
				}
			}
		}
		pw.println(ans);
		pw.flush();
	}

	static long[][] C = new long[20][20];

	static long[] p2 = new long[20], p8 = new long[20];

	static long A(int X, int y){
		long res = 1;
		for(long i=X; i>=X-y+1; i--) res = (res * i)%P;
		return res;
	}

	static long countFor(int NL, int x1, int x2, int x3, int x4, int x5, int x6){
		int[] a = new int[10];
	//	System.out.println(" here with "+x1+" "+x2+" "+x3+" "+x4+" "+x5+" "+x6);
		a[x1]++;
		a[x2]++;
		a[x3]++;
		a[x4]++;
		a[x5]++;
		a[x6]++;
		a[NL]++;
		long res = 1;
		for(int i=0; i<10; i++){
			if(a[i]>0)
				res = (res * A(N[i], a[i]))%P;
		}
	//	System.out.println("result = "+res);
		return res;
	}

	static int[] N1 = new int[10];

	static void naiveCount(){
		for(int i=1; i<=M; i++){
			int numL = numLuckyIn(i);
			N1[numL]++;
		}
	}

	static void countNArray(){
		if(M<1000000){
			for(int i=1; i<=M; i++){
				int numL = numLuckyIn(i);
				N[numL]++;
			}
			return;
		}
		L = (""+M).length();
		int[][] A = new int[10001][10];
		int pow = 1;
		for(int i=0; i<L-5; i++) pow *= 10;
		for(int num=0; num<pow; num++){
			int NL = numLuckyIn(num);
			A[num][NL]++;
		}
		for(int NL=0; NL<=9; NL++) T[0][NL] = A[0][NL];
		for(int i=1; i<10001; i++)
			for(int NL=0; NL<=9; NL++)
				T[i][NL] = T[i-1][NL] + A[i][NL];
		for(int i=0; i<=9; i++) countFor(i);
	}

	static void countFor(int K){ // count N[K]
		long r = 0;
		for(int i=1; i<L; i++){
			if(i<K) continue;
			if(K!=0) r += (C[i-1][K-1]*p2[K]*p8[i-K] + ((i!=K)? C[i-1][K]*p2[K]*7*p8[i-1-K] : 0));
			else if(i>0) r += p2[K]*p8[i-K-1]*7;
		}
		r = (r+countSameLengthFor(K))%P;
		N[K] = (int) r;
	}

	static long countSameLengthFor(int K){
		int num = Integer.parseInt((""+M).substring(0, 5)), suf = Integer.parseInt((""+M).substring(5, L));;
		long res = 0;
		for(int x1=1; x1<=9; x1++){
			for(int x2=0; x2<=9; x2++){
				for(int x3=0; x3<=9; x3++){
					for(int x4=0; x4<=9; x4++){
						for(int x5=0; x5<=9; x5++){
							int FIVE = x5+10*x4+100*x3+1000*x2+10000*x1;
							if(FIVE>num) continue;
							if(FIVE==num){
								res = (res + T[suf][K])%P;
							}
							else{
								res = (res + T[10000][K])%P;
							}
						}
					}
				}
			}
		}
		return res;
	}

	static int[][] T = new int[10001][10];

	static int L;

	static int numLuckyIn(int N){
		String s = ""+N;
		int t = 0;
		for(int i=0; i<s.length(); i++) if(s.charAt(i)=='4' || s.charAt(i)=='7') t++;
		return t;
	}

	static int[] N = new int[10]; // N[K] = number of numbers in [1,M] that contain exactly K lucky digits.

	static int M;

	static final long P = 1000000007;

	static StringTokenizer st;
	static BufferedReader rd;
	static PrintWriter pw;
}


import java.util.Scanner;

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

        int n=in.nextInt(),k=in.nextInt(),t=in.nextInt();
        if(t<=k)out.print(t);
        else if(k<t && t<=n)out.print(k);
        else out.print(Math.min(k,n+k-t));

        out.close();
    }
}


import java.util.*;

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

    Scanner sc = new Scanner(System.in);

    boolean c = false;

    int n = sc.nextInt(); int res = 0; int[] a = new int[n];

    for(int i = 0; i < n; i++) a[i] = sc.nextInt();
    Arrays.sort(a);

    for(int i = 0; i < n; i++) if (a[i]==a[1]) {res++; c = true;}

      System.out.println(res);

    }
}


import java.util.*;
public class AnotherOne
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
       String input = sc.nextLine();
       String[] numbers = input.split(" ");
       int a,b,c,min;
       a=Integer.parseInt(numbers[0])+Interger.parseInt(numbers[3]);
       b=Integer.parseInt(numbers[1])+Integer.parseInt(numbers[3]);
       if(a==b)
          System.out.println(2*a);
        else
        {
            if(a>b)
              min=b;
            else
              min=a;
            System.out.println(2*min+1);
        }

    }
}


import java.util.*;

public class KingMoves{
       public static void main (String[] args){
              Scanner kbd = new Scanner(System.in);
              int counter = 0;
              String input = kbd.nextLine();
              char c = input.charAt(0);
              int x = 0;
               String r = input.charAt(1) + "";
               int y = Integer.parseInt(r) + 0;

                switch (c) {
                 case 'a': x = 1;break;
                 case 'b': x = 2;break;
                 case 'c': x = 3;break;
                 case 'd': x = 4;break;
                 case 'e': x = 5;break;
                 case 'f': x = 6;break;
                 case 'g': x = 7;break;
                 case 'h': x = 8;break;
              }
              int east = x;
              int west = x;
              int nEastX = x;
              int sEastX = x;
              int nWestX = x;
              int sWestX = x;
              int north = y;
              int south = y;
              int nEastY = y;
              int sEastY = y;
       	int nWestY = y;
              int sWestY = y;

            	       east++;
                     if (east <= 8) {
                	       counter++;
                     }

                     west--;
                     if (west > 0) {
                	       counter++;
                     }

			north++;
                     if (north <= 8) {
                	       counter++;
                     }

                     south--;
                     if (south > 0) {
                	       counter++;
                     }

                     nEastY++;
                     nEastX++;
                     if(nEastX <= 8 && nEastY <= 8 ){
                	       counter++;
                     }

			nWestY++;
			nWestX--;
			if(nWestX > 0 && nWestY <= 8){
				counter++;
			}

			sEastY--;
			sEastX++;
			if(sEastX <= 8 && sEastY > 0){
				counter++;
			}

			sWestY--;
			sWestX--;
			if(sWestX > 0 && sWestY > 0){
				counter++;
			}

			System.out.println(counter);

                     }
              }
       }
}


import com.sun.security.auth.SolarisNumericUserPrincipal;
import jdk.management.resource.internal.inst.SocketOutputStreamRMHooks;

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

public class _582B {

    static int n;
    static int T;
    static int[] a;
    static Map<Integer, int[][]> map = new HashMap<>();

    static int[][] F(int T) {
        if (map.containsKey(T)) return map.get(T);
        int[][] ans = new int[n][n];

        if (T == 1) {
            int[][] old = new int[n][n];
            for (int num : a) {
                for (int i = 0; i < n; i++)
                    for (int j = i; j < n; j++) {
                        ans[i][j] = old[i][j];
                        if (i <= num && num <= j) ans[i][j] = Math.max(ans[i][j], old[i][num] + 1);
                    }

                int[][] tmp = old;
                old = ans;
                ans = tmp;
            }
            ans = old;
        } else {
            int[][] left = F(T / 2);
            int[][] right = F(T - T / 2);
            for (int i=0; i<n; i++)
                for (int j=i; j<n; j++)
                    for (int k=i; k<=j; k++)
                        ans[i][j] = Math.max(ans[i][j], left[i][k] + right[k][j]);
        }

        map.put(T, ans);
        return ans;
    }

    static void print(int[][] a) {
        for (int i=0; i<a.length; i++) {
            for (int j=0; j<a[i].length; j++)
                System.out.print(a[i][j] + " ");
            System.out.println();
        }
    }

    public static void main(String[] args) throws Exception {
        Reader.init(System.in);
        BufferedWriter cout = new BufferedWriter(new OutputStreamWriter(System.out));

        n = Reader.nextInt();
        T = Reader.nextInt();
        a = new int[n];
        boolean[] visited = new boolean[333];
        int[] rank = new int[333];
        int pos = 0;
        for (int i = 0; i < n; i++) {
            a[i] = Reader.nextInt();
            visited[a[i]] = true;
        }
        for (int i = 0; i < rank.length; i++)
            if (visited[i]) rank[i] = pos++;
        for (int i = 0; i < n; i++)
            a[i] = rank[a[i]];
        // Now, a[i] is mapped to [0, n)

        System.out.println(F(T)[0][n - 1]);
        cout.close();
    }

    /**
     * Class for buffered reading int and double values
     */
    static class Reader {
        static BufferedReader reader;
        static StringTokenizer tokenizer;

        /**
         * call this method to initialize reader for InputStream
         */
        static void init(InputStream input) {
            reader = new BufferedReader(new InputStreamReader(input));
            tokenizer = new StringTokenizer("");
        }

        /**
         * get next word
         */
        static String next() throws IOException {
            while (!tokenizer.hasMoreTokens()) {
                // TODO add check for eof if necessary
                tokenizer = new StringTokenizer(reader.readLine());
            }
            return tokenizer.nextToken();
        }

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

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

    static class ArrayUtil {
        static void swap(int[] a, int i, int j) {
            int tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }

        static void swap(long[] a, int i, int j) {
            long tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }

        static void swap(double[] a, int i, int j) {
            double tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }

        static void swap(char[] a, int i, int j) {
            char tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }

        static void swap(boolean[] a, int i, int j) {
            boolean tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }

        static void reverse(int[] a, int i, int j) {
            for (; i < j; i++, j--)
                swap(a, i, j);
        }

        static void reverse(long[] a, int i, int j) {
            for (; i < j; i++, j--)
                swap(a, i, j);
        }

        static void reverse(double[] a, int i, int j) {
            for (; i < j; i++, j--)
                swap(a, i, j);
        }

        static void reverse(char[] a, int i, int j) {
            for (; i < j; i++, j--)
                swap(a, i, j);
        }

        static void reverse(boolean[] a, int i, int j) {
            for (; i < j; i++, j--)
                swap(a, i, j);
        }

        static long sum(int[] a) {
            int sum = 0;
            for (int i : a)
                sum += i;
            return sum;
        }

        static long sum(long[] a) {
            long sum = 0;
            for (long i : a)
                sum += i;
            return sum;
        }

        static double sum(double[] a) {
            double sum = 0;
            for (double i : a)
                sum += i;
            return sum;
        }

        static int max(int[] a) {
            int max = Integer.MIN_VALUE;
            for (int i : a)
                if (i > max) max = i;
            return max;
        }

        static int min(int[] a) {
            int min = Integer.MAX_VALUE;
            for (int i : a)
                if (i < min) min = i;
            return min;
        }

        static long max(long[] a) {
            long max = Long.MIN_VALUE;
            for (long i : a)
                if (i > max) max = i;
            return max;
        }

        static long min(long[] a) {
            long min = Long.MAX_VALUE;
            for (long i : a)
                if (i < min) min = i;
            return min;
        }
    }
}


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

public class Resistance {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        BigInteger a = stdin.nextBigInteger();
        BigInteger b = stdin.nextBigInteger();
        BigInteger res = BigInteger.ZERO;

        while (!a.equals(BigInteger.ZERO)) {
        	// System.out.println(a + ", " + b);
            if (a.compareTo(b) >= 0) {
                res = res.add(a.divide(b));
                a = a.mod(b);
            } else {
            	b = b.subtract(a);
                res = res.add(BigInteger.ONE);
            }
            BigInteger g = b.gcd(a);
            a = a.divide(g);
            b = b.divide(g);
        }

        System.out.println(res);
    }
}


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

public class Main {

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

        new Main().go();
    }

    PrintWriter out;
    Reader in;
    BufferedReader br;

    Main() throws IOException {

        try {

            //br = new BufferedReader( new FileReader("input.txt") );
            in = new Reader("input.txt");
            out = new PrintWriter( new BufferedWriter(new FileWriter("output.txt")) );
        }
        catch (Exception e) {

            //br = new BufferedReader( new InputStreamReader( System.in ) );
            in = new Reader();
            out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );
        }
    }

    void go() throws IOException {

        int t = 1;
        while (t > 0) {
            solve();
            //out.println();
            t--;
        }

        out.flush();
        out.close();
    }

    int inf = 2000000000;
    int mod = 1000000007;
    double eps = 0.000000001;

    int n;
    int m;

    //ArrayList<Integer>[] g = new ArrayList[200010];

    void solve() throws IOException {

        int n = in.nextInt();
        int k = in.nextInt();
        int m = in.nextInt();
        int a = in.nextInt();

        Pair[] cands = new Pair[n];
        for (int i = 0; i < n; i++)
            cands[i] = new Pair(0, i);
        for (int i = 0; i < a; i++) {
            int x = in.nextInt()-1;
            cands[x].a++;
            cands[x].t = i;
        }

        Arrays.sort(cands);
        int[] pos = new int[n];
        for (int i = 0; i < n; i++)
            pos[cands[i].b] = i;

        int[] same = new int[n];
        int[] sum = new int[n];
        sum[0] = cands[0].a;
        for (int i = 1; i < n; i++) {
            if (cands[i].a == cands[i - 1].a) {
                same[i] = same[i - 1] + 1;
            }
            sum[i] += sum[i-1] + cands[i].a;
        }

        m -= a;
        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            int p = pos[i];
            boolean ok = false;
            int x = k - (n-p) + 1;
            if (p >= n - k && !(cands[p].a == 0 && n > 1)) {
                if (p - x < 0) {
                    if (m > 0 || cands[p].a > 0) {
                        ok = true;
                        ans[i] = 1;
                    }
                }
                else {
                    int r = p - 1;
                    int l = p - x;
                    int need = x * (cands[p].a + 1);
                    need -= sum[r];
                    if (l > 0)
                        need += sum[l-1];

                    //System.err.println(need+" "+i);

                    if (need > m) {
                        ok = true;
                        ans[i] = 1;
                    }
                }
            }

            if (!ok) {

                int v = cands[n-k].a;
                if (cands[p].a + m > v) {
                    ans[i] = 2;
                }
                else {
                    ans[i] = 3;
                }
            }
        }

        for (int i = 0; i < n; i++)
            out.print(ans[i]+" ");

    }

    class Pair implements Comparable<Pair>{

        int a;
        int b;
        int t = 0;
        Pair(int a, int b) {

            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {

            if (a > p.a) return 1;
            if (a < p.a) return -1;
            if (t > p.t) return -1;
            if (t < p.t) return 1;
            return 0;
        }
    }

    class Item {

        int a;
        int b;
        int c;

        Item(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

    }

    class Reader {

        BufferedReader  br;
        StringTokenizer tok;

        Reader(String file) throws IOException {
            br = new BufferedReader( new FileReader(file) );
        }

        Reader() throws IOException {
            br = new BufferedReader( new InputStreamReader(System.in) );
        }

        String next() throws IOException {

            while (tok == null || !tok.hasMoreElements())
                tok = new StringTokenizer(br.readLine());
            return tok.nextToken();
        }

        int nextInt() throws NumberFormatException, IOException {
            return Integer.valueOf(next());
        }

        long nextLong() throws NumberFormatException, IOException {
            return Long.valueOf(next());
        }

        double nextDouble() throws NumberFormatException, IOException {
            return Double.valueOf(next());
        }

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

    }

}


import java.io.*;
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;
import static java.lang.String.*;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                                            //(new FileReader("input.in"));
        StringBuilder out = new StringBuilder();
        StringTokenizer tk;
        Reader.init(System.in);
        //PrintWriter pw = new PrintWriter("output.out", "UTF-8");

        tk = new StringTokenizer(in.readLine());
        double a = parseDouble(tk.nextToken());
        double b = parseDouble(tk.nextToken());
        double c = parseDouble(tk.nextToken());
        double d = parseDouble(tk.nextToken());

        if(abs(a/b-c/d) <= 1e-9)
            System.out.println("0/1");
        else if(a/b > c/d) {
            double x = a*d-b*c,y = a*d;

            long g = gcd((long)x,(long)y);
            x /= g;
            y /= g;

            System.out.println((int)x+"/"+(int)y);
        } else {
            double x = b*c-a*d,y = b*c;

            long g = gcd((long)x,(long)y);

            x /= g;
            y /= g;

            System.out.println((int)x+"/"+(int)y);
        }
    }

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


import java.util.*;
import java.io.*;
public class Palindrome
{
	 public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		int b=0;
		for(int i=0,int k=s.length()-1;i!=k||i+1!=k;i++,k--)
		{
			if(s.charAt[i]==s.chart[k])
			{

			}
			else if(s.charAt[i]==s.charAt[0])
			{
				b++;

			}
			else
			{
				 b=1;
				break;
			}
		}
			if{b==1}
				System.out println(s.length());
			if{b==0}
				System.out.println(s.length()-1);
			else
				System.out.println(0);

	}
}


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

import java.util.Scanner;
import java.io.IOException;
import static java.lang.Integer.max;
import static java.lang.Math.abs;
/**
 *
 * @author Sergey
 */
public class Main {
        private static final Scanner scanner = new Scanner( System.in );

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        String str = "";

        str = scanner.nextLine();

        int[] arr = new int[6];
        int t1, t2;

        for(int i = 0; i < arr.length -1; i++){
            int index = str.indexOf(" ");
            arr[i] = Integer.parseInt(str.substring(0, index));
            str = str.substring(index+1);
        }

        arr[5] = Integer.parseInt(str);

        t1 = arr[2]; t2 = arr[3];
        arr[2] = t1 + t2;
        arr[3] = t2 - t1;

        t1 = arr[4]; t2 = arr[5];
        arr[4] = t1 + t2;
        arr[5] = t2 - t1;

        arr[0] *= 2;
        arr[1] *= 2;

        arr[2]= arr[2] / arr[0] + ((arr[2] > 0)? 1 : 0);
        arr[4] = arr[4] / arr[0] + ((arr[4] > 0)? 1 : 0);
        arr[3] = arr[3] / arr[1] + ((arr[3] > 0)? 1 : 0);
        arr[5] = arr[5] / arr[1] + ((arr[5] > 0)? 1 : 0);

        System.out.print(max(abs(arr[5] - arr[3]), abs(arr[4] - arr[2])));
    }
}


/* IMPORTANT: Multiple classes and nested static classes are supported */

/*
 * uncomment this if you want to read input.
//imports for BufferedReader
import java.io.BufferedReader;
import java.io.InputStreamReader;

//import for Scanner and other utility  classes
*/import java.util.*;

public class TestClass {
    public static void main(String args[] ) throws Exception {
        /*
         * Read input from stdin and provide input before running
         * Use either of these methods for input

        //BufferedReader
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int N = Integer.parseInt(line);

        //Scanner
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();

        for (int i = 0; i < N; i++) {
            System.out.println("hello world");
        }
        */
Scanner s=new Scanner(System.in);
int a[]=new int[25];
for(int i=1;i<25;i++){
    a[i]=s.nextInt();
}
int c1=a[1],c2=a[5],c3=a[13],c4=a[9],c5=a[17],c6=a[21];
if(a[4]==c1&&a[2]==c1&&a[3]==c1&&a[12]==c4&&a[9]==c4&&a[10]==c4&&a[11]==c4)
{

    if(a[5]==a[6]&&a[19]==a[20]&&a[5]==a[19]){
                System.out.println("YES");}
            else{
    System.out.println("NO");
}
}
else if(a[8]==c2&&a[6]==c2&&a[7]==c2&&a[23]==c6&&a[24]==c6&&a[21]==c6&&a[22]==c6){
       if(a[17]==a[19]&&a[1]==a[2]&&a[17]==a[1]){
       {
                System.out.println("YES");
       }
       else
       {
        System.out.println("NO");
       }
}

else if(a[16]==c3&&a[14]==c3&&a[15]==c3&&a[20]==c5&&a[17]==c5&&a[18]==c5&&a[19]==c5)
{
     if(a[7]==a[5]&&a[2]==a[4]&&a[5]==a[2])
     {
                System.out.println("YES");
     }
     else
     {
        System.out.println("NO");
     }
}

else{
    System.out.println("NO");
}
        //System.out.println("Hello World!");
    }


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

public class AA {
	public static void main(String[] args) throws IOException {
		int n = 3200000;
		int[] primes = new int[230209];
		int c = 0;
		boolean[] isComposite = new boolean[n];
		for (int i = 2; i < n; i++) {
			if (!isComposite[i]) {
				primes[c++] = i;
				for (int j = i + i; j < n; j += i) {
					isComposite[j] = true;
				}
			}
		}
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String s = r.readLine();
		long x = new Long(s);
		long xx = x;
		if (isPrime(x)) {
			System.out.println(1);
			System.out.println(0);
			return;
		}
		int primeFactors = 0;
		long winPosition = 1;
		for (int i = 0; i < primes.length; i++) {
			while (x % primes[i] == 0) {
				x /= primes[i];
				primeFactors++;
				winPosition *= primes[i];
				if (primeFactors == 2 && winPosition != xx) {
					System.out.println(1);
					System.out.println(winPosition);
					return;
				}
			}
		}
		System.out.println(2);
	}

	private static boolean isPrime(long x) {
		if (x == 1 || x == 2)
			return true;
		if (x % 2 == 0)
			return false;
		for (long i = 3; i * i <= x; i += 2)
			if (x % i == 0)
				return false;
		return true;
	}
}


public class A976 {

	public static void main(String[] args) {
		sc sc= new sc();
		int a = sc.nextInt();
		String s = sc.next();
		int z= countZ(s);
		if(s.equals("0"))
			System.out.println("0");
		else
		if (z==0)
			System.out.println("1");
		else {
			System.out.print("1");
			for (int i = 0; i < z; i++) {
				System.out.print("0");
			}
		}

	}
	public static int countZ (String s) {
		int x =0;
		for (int i = 0; i < s.length(); i++) {
			if(s.charAt(i)=='0')
				x++;
		}
		return x;
	}

}
class sc {
	BufferedReader br;
	StringTokenizer st;

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

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

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

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

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

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


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

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Jatin Yadav
 */
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);
    EasterEggs solver = new EasterEggs();
    solver.solve(1, in, out);
    out.close();
  }

  static class EasterEggs {
    InputReader in;
    PrintWriter out;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
      this.in = in;
      this.out = out;
      //int t = ni();
      //for (int i = 1; i <= t; i++) {
      //out.print("Case #" + i + ": ");
      //solve();
      //out.println();
      //}
      //for (int i = 0; i < t; i++)
      solve();
    }

    public void solve() {
      int n = ni();
      String s1 = "ROYG";
      String s2 = "BIV";
      int times = n / 4;
      int rem = n % 4;
      String ans = s1.repeat(Math.max(0, times))
          + s2.substring(0, rem);
      out.println(ans);
    }

    private int ni() {
      return in.nextInt();
    }
  }

  static class InputReader {
    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar;
    private int snumChars;
    private InputReader.SpaceCharFilter filter;

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

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

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

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

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


package z;

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc .nextInt();
        ArrayList<Exam> exams = new ArrayList<Exam>();
        Map<Integer,Exam> dayExam = new HashMap<>();
        int ddd;
        for(int i=0;i<m;i++){
            exams.add(new Exam(sc.nextInt(), ddd = sc.nextInt(),sc.nextInt()));
            dayExam.put(ddd,exams.get(i));
        }
        Collections.sort(exams);
        int kk = 0;
        String output="";
        for(int i =1 ; i<=n;i++){
            int k = 0;
            if(dayExam.keySet().contains(i)){
                if(dayExam.get(i).prepDays!=0) {
                    System.out.println("-1");
                    System.exit(0);
                }
                output+= (m+1) + " ";
                kk++;
                continue;
            }
            int o=0;
            while(k < m && (o = exams.get(k).prepare(i)) == 0){
                k++;
            }
            output+=o+" ";
            k++;

        }
        output.substring(0,output.length());
        System.out.println(output);

    }
}
class Exam implements Comparable<Exam>{
    int examDay;
    int prepDays;
    int questionsDays;
    int examID;
    static int examsCounter=1;

    public Exam(int questionsDays,int examDay, int prepDays) {
        this.examID=examsCounter;
        examsCounter++;
        this.questionsDays=questionsDays;
        this.examDay = examDay;
        this.prepDays = prepDays;
    }
    int prepare(int i){
        if (prepDays!=0&&questionsDays<=i) {
            prepDays--;
            return examID;
            }
            return 0;
    }

    @Override
    public int compareTo(Exam other) {
        if(this.questionsDays<other.questionsDays)
            return -1;
        else if (this.questionsDays==other.questionsDays)
            return Integer.compare(this.examDay,other.examDay);
        else
            return 1;
    }
}


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

public class MyClass {
    public static void main(String args[]) {
        ABCDEFGHIJKLMNOPQRSTUVWXYZScanner scan = new ABCDEFGHIJKLMNOPQRSTUVWXYZScanner();
        long a = scan.nextInt(), b = scan.nextInt(), c = scan.nextInt();
        long max = 0;
        for(int i = 0; i < 7; i++) {
            long aa = calcA(i, a);
            long bb = calcB(i, b);
            long cc = calcC(i, c);
            //if(i == 6) System.out.println(aa + " " + bb + " " + cc);
            long min = Math.min(aa, Math.min(bb, cc));
            max = Math.max(max, min);
        }
        System.out.println(max);

    }

    static long calcA(int i, int a) {
        long have = a/3;
        long left = a - have * 3;
        have*=7;
        for(int j = 0; j < 7; j++) {
            if(left < 0) break;
            int get = (j+i)%7;
            if(get == 0 || get == 3 || get == 6) {
                left--;
            }
            if(left >= 0) have++;
        }
        return have;
    }

    static long calcB(int i, int b) {
        long have = b/2;
        long left = b - have * 2;
        have*=7;
        for(int j = 0; j < 7; j++) {
            if(left < 0) break;
            int get = (j+i)%7;
            if(get == 1 || get == 5) {
                left--;
            }
            if(left >= 0) have++;
        }
        return have;
    }

    static long calcC(int i, int b) {
        long have = b/2;
        long left = b - have * 2;
        have*=7;
        for(int j = 0; j < 7; j++) {
            if(left < 0) break;
            int get = (j+i)%7;
            if(get == 2 || get == 4) {
                left--;
            }
            if(left >= 0) have++;
        }
        return have;
    }

    static class ABCDEFGHIJKLMNOPQRSTUVWXYZScanner
    {
        BufferedReader br;
        StringTokenizer st;

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

        int[] nia(int n) {
            int[] res =  new int[n];
            for(int i = 0; i < n; i++) res[i] = nextInt();
            return res;
        }

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

        long[] nla(int n) {
            long[] res =  new long[n];
            for(int i = 0; i < n; i++) res[i] = nextLong();
            return res;
        }

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

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


 import java.util.*;
   public class Main{
   public static void main (string [] args){
          int n=0;
  Scanner in = new Scanner (System.in);

      int x = in.nextInt();

     if(x==1 || x==2){
  System.out.print("2");
}

     if(x>=3 && x<6)
   System.out.print("3");

  if(x>=6 && x<=13)
    System.out.print("5");

 if(x>=14 && x<=25)
    System.out.print("7");

if(x>=26 && x<=41)
    System.out.print("9");

if(x>=42 && x<=61)
    System.out.print("11");

if(x>=62 && x<=85)
    System.out.print("13");

if(x>=86 && x<=100)
    System.out.print("15");

}
}


import java.io.InputStreamReader;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.io.InputStream;

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

class TaskB {
    /////////////////////////////////////////////////////////////
    public void solve(int testNumber, FastScanner in, FastPrinter out) {
    int n=in.nextInt(),d=in.nextInt();
     int[] c= in.readIntArray(n);
      boolean[] dp= new boolean[520005];
        dp[0]=true;
      int max=0;
        for (int i = 0; i < n; i++) {
            for (int j = 500004-c[i]; j >=0 ; j--) {
              if(dp[j]){dp[j+c[i]]=true;
             // max=Math.max(max,j+c[i]);
              }
            }
        }
    //    deb(dp);
    int days=0,cur=0;
     int cc=1;
        while(cc==1){
        cc=0;
           int i;
            for ( i = cur+d; i >cur; i--) {
              if(dp[i]){
                  cc=1;
                  cur=i;
               //   System.out.println(cur);
                  break;
              }
            }
        if(cc==0)break;
        days++;

        }
        out.println(cur+" "+days);

    }
}

class FastScanner extends BufferedReader {

    public FastScanner(InputStream is) {
        super(new InputStreamReader(is));
    }

    public int read() {
        try {
            int ret = super.read();
//            if (isEOF && ret < 0) {
//                throw new InputMismatchException();
//            }
//            isEOF = ret == -1;
            return ret;
        } catch (IOException e) {
            throw new InputMismatchException();
        }
    }

    static boolean isWhiteSpace(int c) {
        return c >= 0 && c <= 32;
    }

    public int nextInt() {
        int c = read();
        while (isWhiteSpace(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int ret = 0;
        while (c >= 0 && !isWhiteSpace(c)) {
            if (c < '0' || c > '9') {
                throw new NumberFormatException("digit expected " + (char) c
                        + " found");
            }
            ret = ret * 10 + c - '0';
            c = read();
        }
        return ret * sgn;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }

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

}

class FastPrinter extends PrintWriter {

    public FastPrinter(OutputStream out) {
        super(out);
    }

    public FastPrinter(Writer out) {
        super(out);
    }

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;

public class AlyonaAndNumbers
{
	public static void main(String[] args)
	{
		InputStream is=System.in;
		OutputStream out=System.out;
		FastScanner scan=new FastScanner(is);
		int n=scan.nextInt();
		int m=scan.nextInt();
		int count=0;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				if((i+j)%5==0)
				{
					count++;
					//System.out.println(i+" "+j);
				}
			}
		}
		out.println(count);
	}

}
  class FastScanner
		 {
		    StringTokenizer st;
		    BufferedReader br;

		    public FastScanner(InputStream is)
		     {
		 	  br=new BufferedReader(new InputStreamReader(is));
		     }
		    public FastScanner(File file)
		    {
		 	  try
		 	   {
		 		 br=new BufferedReader(new FileReader(file));
		 	   }
		 	  catch (FileNotFoundException e)
		 	   {
		 	 		e.printStackTrace();
		 	   }
		    }
		    public String next()
		    {
		 	   while(st==null||! st.hasMoreElements())
		 	    {
		 		 String s=null;
		 		 try
		 		   {
		 			 s=br.readLine();
		 		   }
		 		 catch(IOException e)
		 		   {
		 			 e.printStackTrace();
		 		   }

		 		 if(s==null)
		 		   {
		 			 return null;
		 		   }
		 		 st=new StringTokenizer(s);
		 	    }
		 	   return st.nextToken();

		    }

		    public int nextInt()
		    {

		 	   return Integer.parseInt(next());
		    }

		 }

		 class FastPrinter extends PrintWriter
		 {
		     public FastPrinter(OutputStream out)
		     {

		    	 super(out);
		     }

		     public FastPrinter(Writer out)
		     {
		         super(out);
		     }

		 }


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

public class R
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        int lo = 1, hi = n;
        int mid = 0;
        int ans = 0;
        while( lo < hi ) {
            mid = (lo + hi)>>1;
            if ( is(mid,n,k) ) {
                ans = mid;
                hi = mid;
            } else {
                lo = mid + 1;
            }
        System.out.println(lo);
    }
    public static boolean is( int mid, int n, int k ) {
        int val = mid, temp = 0;
        int x = k;
        if( mid == n) return true;
        while( val < n ) {

            temp = (mid/x);
            if(temp == 0) { return false; }
            val += temp;
            x *= k;
        }
        return true;
    }
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Wolfgang Beyer
 */
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);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long a1 = in.nextLong();
            long b1 = in.nextLong();
            long a2 = in.nextLong();
            long b2 = in.nextLong();
            long L = in.nextLong();
            long R = in.nextLong();

            //Extended Euclid for a1 and a2
            long r0 = a1;
            long r1 = a2;
            //r0 = 240;
            //r1 = 46;
            long r2;

            long s0 = 1;
            long s1 = 0;
            long s2;

            long t0 = 0;
            long t1 = 1;
            long t2;

            while (r0 % r1 != 0) {
                long q = r0 / r1;
                r2 = r0 - q * r1;
                s2 = s0 - q * s1;
                t2 = t0 - q * t1;

                r0 = r1;
                r1 = r2;
                s0 = s1;
                s1 = s2;
                t0 = t1;
                t1 = t2;
            }
            if ((b1 - b2) % r1 != 0) {
                out.println(0);
                return;
            }
            //System.out.println(r1 + " " + s1 + " " + t1);
            //long x = b1 * t1 * a2 + b2 * s1 * a1;
            //long x = (b1 * t1 * a2 + b2 * s1 * a1) / r1;
            long scm = Math.abs(a1 * a2) / r1;
            //System.out.println("scm: " + scm);

            BigInteger x2 = BigInteger.valueOf(b1).multiply(BigInteger.valueOf(t1)).multiply(BigInteger.valueOf(a2)).add(BigInteger.valueOf(b2).multiply(BigInteger.valueOf(s1)).multiply(BigInteger.valueOf(a1))).divide(BigInteger.valueOf(r1));
            BigInteger x3 = x2.mod(BigInteger.valueOf(scm));
            long x = x3.longValue();
            //System.out.println("x: " + x3.toString());
            //System.out.println("x: " + x);

            if ((R < b1) || (R < b2)) {
                out.println(0);
                return;
            }
            L = Math.max(L, b1);
            L = Math.max(L, b2);
            R = Math.max(R, b1);
            R = Math.max(R, b2);

        /*System.out.println(L + " " + R);
        long q1 = (long) Math.ceil((double) (L - x) / scm) - 1;
        long q2 = (long) Math.floor((double) (R - x) / scm) + 1;
        System.out.println((double) (L - x) / scm);
        System.out.println((double) (R - x) / scm);
        System.out.println(q1 + " " + q2);
        out.println(Math.abs(q2 - q1) - 1);*/

            long v1 = Math.round((double) (L - x) / scm);
            long lower = x + v1 * scm;
            while (lower >= L) lower -= scm;
            while (lower + scm < L) lower += scm;
            long v2 = Math.round((double) (R - x) / scm);
            long higher = x + v2 * scm;
            while (higher <= R) higher += scm;
            while (higher - scm > R) higher -= scm;
            out.println((higher - lower) / scm - 1);
        }

    }

    static class InputReader {
        private static BufferedReader in;
        private static StringTokenizer tok;

        public InputReader(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
        }

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

        public String next() {
            try {
                while (tok == null || !tok.hasMoreTokens()) {
                    tok = new StringTokenizer(in.readLine());
                }
            } catch (IOException ex) {
                System.err.println("An IOException was caught :" + ex.getMessage());
            }
            return tok.nextToken();
        }

    }
}


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

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();// 人数
        int m = scan.nextInt();// 信息量
        boolean boss[] = new boolean[n + 1];// 是否是leader
        boolean find[] = new boolean[n + 1];// 消息中出现的人中的leader
        Arrays.fill(boss, true);
        int home = 0;// 房间人数
        boolean in[] = new boolean[n + 1];// 是否在房间中
        int leader = 0;// 当前leader
        int sum = 0;// leader人数;
        for (int i = 1; i <= m; i++) {
            String s = scan.next();
            int x = scan.nextInt();
            boss[x] = false;
            if (s.equals("+")) {
                if (home == 0&&x!=leader) {
                    leader = x;
                    sum++;
                }
                home++;
                in[x] = true;
            } else if (s.equals("-")) {
                if (in[x] == false) {
                    sum = 0;
                    if (home == 0&&x!=leader) {
                        leader = x;
                        sum++;
                    }
                    // System.out.println(sum+"　"+home);
                } else if (in[x] == true) {
                    if (home == 0&&x!=leader) {
                        leader = x;
                        sum++;
                        in[x] = false;
                    }
                    home--;
                }
            }
//          System.out.println(home+" "+leader+" "+sum);
        }
//      System.out.println(leader);
//       System.out.println(sum);
        if (sum == 1) {
            boss[leader] = true;
        }
        int count = 0;
        for (int i = 1; i <= n; i++) {
            if (boss[i])
                count++;
        }
        System.out.println(count);
        for (int i = 1; i <= n; i++) {
            if (boss[i])
                System.out.print(i + " ");
        }
    }
}


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

public class Main {
    static long pow(int base, int exp)
    {
        long res = 1;
        while(exp > 0)
        {
            if(exp % 2 == 1)
                res = (res*base)%mod;
            base = (base*base)%mod;
            exp /= 2;
        }
        return res;
    }
    static int mod = 1000000007;
    static void zap() throws IOException {
        char[] num = nextToken().toCharArray();
        int len = num.length;
        long sum = 0;
        for(int i=len-1;i>=0;i--)
        {
            if(num[i] == '1')
                sum = (sum + pow(2, len-i-1) * pow(2, len-1))%mod;
        }
        out.println(sum);
    }

    static BufferedReader br;
    static StringTokenizer st;
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        InputStream input = System.in;
        br = new BufferedReader(new InputStreamReader(input));
        out = new PrintWriter(System.out);
        zap();
        out.close();
    }

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

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

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

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


import java.util.Scanner;

public class coins{

	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int x = s.nextInt();
		int v = x;
		int highP = x;
		int count = 0;
		StringBuilder output = new StringBuilder();

		while(v != 0){
			for(int i = highP; i >= 2; i--)
			{
				if(isPrime(i) && i <= v && v-i != 1){
					if(count == 1 && !isPrime(v-i) && v-i!= 0) break;
					highP = v-i;
					v -= i;
					output.append(i + " ");
					count++;
					break;
				}
			}
		}
		System.out.println(count);
		System.out.println(output);

	}

	public static boolean isPrime(int num) {
		if (num % 2 == 0 && num != 2) return false;
        for (int i = 3; i * i <= num; i += 2)
            if (num % i == 0) return false;
        return true;
    }

}


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

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {

            int m = in.nextInt();
            int n = in.nextInt();
            int time = in.nextInt();
            int[] cost = new int[n];

            int v = 0;
            for (int i = 0; i < n; ++i) {
                cost[i] = in.nextInt();
                v += cost[i];
            }

            Arrays.sort(cost);
            int h = cost[0] * m;

            int solved = 0;

            int tmp = time;
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    if (time >= cost[i]) {
                        time -= cost[i];
                        solved++;
                    }
                }
            }

            int solved2 = 0;
            time = tmp;
            for (int j = 0; j < m; ++j) {
                for (int i = 0; i < n; ++i) {
                    if (time >= cost[i]) {
                        time -= cost[i];
                        solved2 += 1 + (i == n - 1 ? 1 : 0);
                    }
                }
            }

            out.println(Math.max(solved, solved2));
        }

    }

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

    }
}


import java.util.Scanner;
public class Intersection {
	public static int GCD(int a, int b, int c){
		if (a==0){
			a=Math.max(b,c);
		}
		if (b==0){
			b=Math.max(a,c);
		}
		if (c==0){
			c=Math.max(a,c);
		}
	int limit = Math.min(a, b);
    limit = Math.min(limit, c);
    for(int n = limit; n >= 2; n--)
    {
        if ( (a % n == 0) && (b % n == 0) && (c % n == 0) ) {
            return n;
        }
    }

    return 1;
	}

    public static void main (String [] args){
    	Scanner sc=new Scanner(System.in);
    	String S1[]=sc.nextLine().split(" ");
    	String S2[]=sc.nextLine().split(" ");
    	int I1[]=new int [S1.length];
    	int I2[]=new int [S1.length];

    	for (int i=0; i<S1.length; i++){
    		I1[i]=Integer.parseInt(S1[i]);
    		I2[i]=Integer.parseInt(S2[i]);
    	}
    	boolean neg=false;
    	if (I1[2]==-I2[2])
    		neg=true;

    	int G1=GCD(I1[0],I1[1],I1[2]);
    	int G2=GCD(I2[0],I2[1],I2[2]);

    	for (int i=0; i<3; i++){
    		I1[i]=I1[i]/G1;
    		I2[i]=I2[i]/G2;

    	}

    	if ((I1[0]==0 &&I1[1]==0 &&I1[2]==0)||(I2[0]==0 &&I2[1]==0 &&I2[2]==0))
    		System.out.println("-1");
    	else{
    	if ((I1[0]==-I2[0] && I1[1]==-I2[1]  && neg==false) || (I1[0]==0 && I1[1]==0 && I1[2]!=0) || (I2[0]==0 && I2[1]==0 && I2[2]!=0) || (I1[0]==I2[0] &&I1[1]==I2[1] && I1[2]!=I2[2])){
    		System.out.println("0");
    	}
    	else{
    	if (I1[0]==I2[0] && I1[1]==I2[1] ){
    		System.out.println("-1");
    	}
    	else
    		System.out.println("1");

    	}
    	}
    }

}


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Stages {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int k = input.nextInt();
        int[] candi = new int[n];
        input.nextLine();
        String str = input.nextLine();
        for (int i = 0; i < n; i++) {
            candi[i] = (int) str.charAt(i);
        }
//        for (int i = 0; i < candi.length; i++)
//            System.out.print(((char) candi[i])+",");
//        System.out.println();
        Sort.mergeSort(candi);
//        for (int i = 0; i < candi.length; i++)
//            System.out.print(((char) candi[i])+",");
//        char[] res = new char[(int) Math.ceil(candi.length / 2) + 2];
        List<Character> res = new ArrayList<>();
        res.add((char) candi[0]);
        int i = 0, j = 0;
        while (j < candi.length) {
            if ((candi[j] - res.get(i)) >= 2) {
                i++;
                res.add((char) candi[j]);
            }
            j++;
        }
        if (k <= n && k <= res.toArray().length) {
            int count = 0;
            for (int h = 0; h < k; h++) {
                count += ((int) res.get(h))-96;
            }
            System.out.print(count);
        } else
            System.out.print(-1);
    }
}


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

public class Pair {
    int first, second;
    Pair(int a, int b) {
        first = a;
        second = b;
    }
};

public class Main {
    static int inf = (1 << 30);
    public static void main(String arg[]) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] a = new int[4], b = new int[4], c = new int[4], d = new int[4];
        Pair[] p = new Pair[4];

        int leastMoney = inf, position = -1;
        for(int i = 0; i < 4; i++) {
            a[i] = input.nextInt();
            b[i] = input.nextInt();
            c[i] = input.nextInt();
            d[i] = input.nextInt();
            p[i] = new Pair(Math.min(a[i], b[i]), Math.min(c[i], d[i]));
            if (p[i].first + p[i].second < leastMoney) {
                leastMoney = p[i].first + p[i].second;
                position = i;
            }
        }
        if (leastMoney > n) {
            System.out.println(-1);
        } else {
            System.out.println((position + 1) + " " + p[position].first + " " + (n - p[position].first));
        }
    }
}


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

public class GuessTheTree {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	boolean solve() throws IOException {
		int n = nextInt();
		int initN = n;
		List<Integer> szList = new ArrayList<>();
		int leaves = 0;

		for (int i = 0; i < n; i++) {
			int x = nextInt();
			if (x == 1) {
				leaves++;
			} else {
				szList.add(x);
			}
		}

		n = szList.size();

		if (leaves <= n) {
			return false;
		}

		Collections.sort(szList);
		Collections.reverse(szList);

		int[] sz = new int[n];
		for (int i = 0; i < sz.length; i++) {
			sz[i] = szList.get(i);
		}

		if (sz[0] != initN) {
			return false;
		}

		int[] maskCnt = new int[1 << n];
		int[] maskSum = new int[1 << n];
		for (int i = 0; i < n; i++) {
			maskCnt[1 << i] = 1;
			maskSum[1 << i] = sz[i];
		}

		for (int mask = 1; mask < (1 << n); mask++) {
			int low = Integer.lowestOneBit(mask);
			maskCnt[mask] = maskCnt[low] + maskCnt[mask ^ low];
			maskSum[mask] = maskSum[low] + maskSum[mask ^ low];
		}

		boolean[][][] dp = new boolean[n + 1][leaves + 1][1 << n];
		// current node, unassigned leaves, unassigned nodes

		final int ALL = (1 << n) - 1;

		dp[0][leaves][ALL ^ 1] = true;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= leaves; j++) {
				for (int mask = 0; mask < (1 << n); mask++) {
					if (!dp[i][j][mask] || test(mask, i)) {
						continue;
					}
					for (int sub = mask; ; sub = (sub - 1) & mask) {
						int leavesHere = sz[i] - 1 - maskSum[sub];
						if (leavesHere >= 0 && leavesHere <= j
								&& leavesHere + maskCnt[sub] >= 2) {
							dp[i + 1][j - leavesHere][mask ^ sub] = true;
						}
						if (sub == 0) {
							break;
						}
					}
				}
			}
		}

		return dp[n][0][0];

	}

	static boolean test(int mask, int i) {
		return ((mask >> i) & 1) == 1;
	}

	void inp() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		out.println(solve() ? "YES" : "NO");
		out.close();
	}

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

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

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

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

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

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


import java.util.Scanner;

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

		int A = sc.nextInt();
		int sum = 0;

		for(int i = 2; i < A; i++){
			int tmp = A;

			while(tmp != 0){
				sum += (tmp % i);
				tmp = tmp/i;
			}
		}

		long g = Library.gcd(sum, A - 2);

		System.out.println(sum/g + "/" + (A - 2)/g);
	}

}


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

public class PowerBoard {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int[] spf = new int[1_000_001];
        Arrays.fill(spf, 1);
        for (int i=2; i<=1_000; i++) if (spf[i]==1)
                for (int j=i; j<=1_000_000; j+=i) if (spf[j]==1)
                        spf[j] = i;
        int N = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());
        boolean[] v = new boolean[20*M+1];
        int[] cnt = new int[20];
        for (int i=1; i<20; i++) {
            for (int j=1; j<=M; j++) {
                if (v[i*j]) continue;
                v[i*j] = true;
                cnt[i]++;
            }
        }
        for (int i=2; i<20; i++)
            cnt[i] += cnt[i-1];
        long now = 1;
        boolean[] power = new boolean[N+1];
        for (int p=2; p<=N; p++) {
            if (power[p]) continue;
            int cpow = 2;
            for (int k=p*p; k<=N; k*=p, cpow++) {
                power[k] = true;
            }
            cpow--;
            now += cnt[cpow];
        }
        System.out.println(now);
    }
}


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

public class Main {
    private final static long mod = 1000000007;

    private final static int MAXN = 100001;

    private static long power(long x, long y, long m) {
        long temp;
        if (y == 0)
            return 1;
        temp = power(x, y / 2, m);
        temp = (temp * temp) % m;
        if (y % 2 == 0)
            return temp;
        else
            return ((x % m) * temp) % m;
    }

    private static long power(long x, long y) {
        return power(x, y, mod);
    }

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

    static int nextPowerOf2(int a) {
        return 1 << nextLog2(a);
    }

    static int nextLog2(int a) {
        return (a == 0 ? 0 : 32 - Integer.numberOfLeadingZeros(a - 1));
    }

    private static long modInverse(long a, long m) {
        long m0 = m;
        long y = 0, x = 1;
        if (m == 1)
            return 0;
        while (a > 1) {
            long q = a / m;
            long t = m;
            m = a % m;
            a = t;
            t = y;
            y = x - q * y;
            x = t;
        }
        if (x < 0)
            x += m0;
        return x;
    }

    private static class Pair<T, U> {
        T a;
        U b;

        public Pair(T a, U b) {
            this.a = a;
            this.b = b;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Pair pair = (Pair) o;
            return a.equals(pair.a) &&
                    b.equals(pair.b);
        }

        @Override
        public int hashCode() {
            return Objects.hash(a, b);
        }

        @Override
        public String toString() {
            return "(" + a +
                    "," + b +
                    ')';
        }
    }

    private static int log[]= new int[MAXN+1];

    private static int getLRMax(int st[][], int L, int R){
        int j = log[R - L + 1];
        return Math.max(st[L][j], st[R - (1 << j) + 1][j]);
    }

    private static int[][] getSparseTable(int array[]){
        int k= log[MAXN]+1;
        int st[][]=new int[MAXN][k+1];

        for (int i = 0; i < array.length; i++)
            st[i][0] = array[i];

        for (int j = 1; j <= k; j++) {
            for (int i = 0; i + (1 << j) <= array.length; i++) {
                st[i][j] = Math.max(st[i][j-1], st[i + (1 << (j - 1))][j - 1]);
            }
        }
        return st;
    }

    private static String bruteForce(int n,int m,int []a) {
        int t, i, j, l, r, c, p, q, ti, tidx, d;
        StringBuilder ans=new StringBuilder();
        List<Integer>list=new ArrayList<>();
        for(int e:a){
            Collections.sort(list);
            int sum=0;
            for(i=0;i<list.size();i++){
                if(sum+list.get(i)<=m-e){
                    sum+=list.get(i);
                }
                else break;
            }
            ans.append(list.size()-i).append(' ');
            list.add(e);
        }
        return ans.toString();
    }

    public static void main(String[] args) throws IOException {
        try (FastReader in = new FastReader();
             FastWriter out = new FastWriter()) {
            int t, i, j,n,k, m, l, r, c, p, q, ti, tidx, d;
            long x, y, z;
            for (t = in.nextInt(), tidx = 1; tidx <= t; tidx++)
            {
                //out.print(String.format("Case #%d: ", tidx));
                n=in.nextInt();
                m=in.nextInt();
                int a[]=in.nextIntArr(n);
                //String bruteforceAns=bruteForce(n,m,a);
                //out.println(bruteforceAns);
                PriorityQueue<Integer> maxHeap = new PriorityQueue<>(Collections.reverseOrder());
                PriorityQueue<Integer> minHeap = new PriorityQueue<>();
                long maxHeapSum=0;
                StringBuilder ans = new StringBuilder();
                for(int e:a) {
                    while(maxHeapSum>m-e&&!maxHeap.isEmpty()){
                        p=maxHeap.poll();
                        minHeap.add(p);
                        maxHeapSum-=p;
                    }
                    maxHeap.add(e);
                    maxHeapSum+=e;
                    while(!minHeap.isEmpty()){
                        p=minHeap.peek();
                        if(maxHeapSum+p<=m){
                            maxHeapSum+=p;
                            minHeap.poll();
                            maxHeap.add(p);
                        }
                        else{
                            break;
                        }
                    }
                    ans.append(minHeap.size());
                    ans.append(' ');
                    if(!maxHeap.isEmpty()){
                        p=maxHeap.poll();
                        minHeap.add(p);
                        maxHeapSum-=p;
                        while(!minHeap.isEmpty()){
                            p=minHeap.peek();
                            if(maxHeapSum+p<=m){
                                maxHeapSum+=p;
                                minHeap.poll();
                                maxHeap.add(p);
                            }
                            else{
                                break;
                            }
                        }
                    }

                }
                out.println(ans.toString());

            }
        }
    }

    static class FastReader implements Closeable {
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        private StringTokenizer st;
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

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

        int[] nextIntArr(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        double[] nextDoubleArr(int n) {
            double[] arr = new double[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextDouble();
            }
            return arr;
        }

        long[] nextLongArr(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        String[] nextStrArr(int n) {
            String[] arr = new String[n];
            for (int i = 0; i < n; i++) {
                arr[i] = next();
            }
            return arr;
        }

        int[][] nextIntArr2(int n, int m) {
            int[][] arr = new int[n][m];
            for (int i = 0; i < n; i++) {
                arr[i] = nextIntArr(m);
            }
            return arr;
        }

        long[][] nextLongArr2(int n, int m) {
            long[][] arr = new long[n][m];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLongArr(m);
            }
            return arr;
        }

        @Override
        public void close() throws IOException {
            br.close();
        }
    }

    static class FastWriter implements Closeable {
        BufferedWriter bw;
        List<String> list = new ArrayList<>();
        Set<String> set = new HashSet<>();

        FastWriter() {
            bw = new BufferedWriter(new OutputStreamWriter(System.out));
        }

        <T> void print(T obj) throws IOException {
            bw.write(obj.toString());
            bw.flush();
        }

        void println() throws IOException {
            print("\n");
        }

        <T> void println(T obj) throws IOException {
            print(obj.toString() + "\n");
        }

        <T> void printArrLn(T[] arr) throws IOException {
            for (int i = 0; i < arr.length - 1; i++) {
                print(arr[i] + " ");
            }
            println(arr[arr.length - 1]);
        }

        <T> void printArr2(T[][] arr) throws IOException {
            for (int j = 0; j < arr.length; j++) {
                for (int i = 0; i < arr[j].length - 1; i++) {
                    print(arr[j][i] + " ");
                }
                println(arr[j][arr.length - 1]);
            }
        }

        <T> void printColl(Collection<T> coll) throws IOException {
            for (T e : coll) {
                print(e + " ");
            }
            println();
        }

        void printCharN(char c, int n) throws IOException {
            for (int i = 0; i < n; i++) {
                print(c);
            }
        }

        void printIntArr2(int[][] arr) throws IOException {
            for (int j = 0; j < arr.length; j++) {
                for (int i = 0; i < arr[j].length - 1; i++) {
                    print(arr[j][i] + " ");
                }
                println(arr[j][arr.length - 1]);
            }
        }

        @Override
        public void close() throws IOException {
            bw.close();
        }
    }

}


import java.util.*;
public class Test {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc =new Scanner(System.in);
		long s =sc.nextLong();
		long x =sc.nextLong();
		long or =s+x;
		long and =s-x;
		long tot=1,to=0;
		if((or & 1) ==0 && (and & 1)==0){
			or = or>>1;
			and =and>>1;
			if(and==0){
				to+=2;
			}
			boolean cd =true;
			while(and!=0 || or!=0){
				if(and%2!=1){
					if(or%2!=0){
						if(x%2==1){
							tot<<=1;
						}
						else{
							System.out.println(0);
							cd =false;
							break;
						}
					}
				}
				and>>=1;
				or>>=1;
				x>>=1;
			}
			if(cd){
				System.out.println((tot-to));
			}
		}
		else{
			System.out.println(0);
		}
	}
}


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class sobel {
	public static boolean check(String s){
		for (int i = 0 ;i < s.length() ; i++){
			if (s.charAt(i) == '8')
				return true;
		}
		return false;
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long  n;
		n = in.nextLong();

		int h = 0;
		while (true) {
			if (check(String.valueOf(n+h))) {
				System.out.print(h);
				System.exit(0);
			}
			h++;
		}
		in.close();
	}

}


import java.util.Scanner;

public class partyLemonade {

	public static int minPrice(int[] price,int[] vol,int volreq)
	{
		int[][] arr=new int[vol.length][volreq+1];

		for(int i=0;i<arr.length;i++)
		{
			for(int j=0;j<arr[0].length;j++)
			{
				if(i==0)
					{
						arr[i][j]=j*price[i];
						//System.out.println("i=0  " + arr[i][j]);
					}

				else if(j==0)
					arr[i][j]=0;

				else {
					if(j>=vol[i])
						arr[i][j]=Math.min(arr[i-1][j], price[i]+arr[i][j-vol[i]]);
					else
						arr[i][j]=Math.min(arr[i-1][j], price[i]);
					/*System.out.println("i j arr[i][j]  "+i+" "+j +" arr  "+arr[i][j]);*/
				}
			}
		}

		return arr[vol.length-1][volreq];
	}

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

		int n=s.nextInt();
		int volreq=s.nextInt();
		int[] price=new int[n];
		for(int i=0;i<n;i++) {
			price[i]=s.nextInt();
		}

		int[] vol=new int[n];

		for(int i=0;i<n;i++)
			vol[i]=(int)Math.pow(2, i);

		System.out.println(minPrice(price, vol, volreq));
	}

}


import java.util.Scanner;
public class LazySecurityGuard{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		System.out.println(2*((int)Math.ceil(2*Math.sqrt(sc.nextInt()))));
	}
}


import java.util.*;

public class Main {

public static void main(String[] args)
	{

       		Scanner sc = new Scanner(System.in);
       		String word = sc.next();
       		int num = sc.nextInt();

       		String[] words = new String[num];
       		for(int i = 0; i < num; i++)
       		{
       			words[i] = sc.next();
       		}

       		for(int i = 0; i < word.length; i++)
       		{
       			for(int j = 0; j < words.length; j++)
       			{
       				String big = words[i] + words[j];
       				if(big.contains(word))
       				{
       					System.out.println("YES");
       					return;
       				}
       			}
       		}
       		System.out.println("NO");
	}
}


import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main {
  public static void main(String[] args) {
    InputStream inputStream;
    if (args.length > 0 && args[0].equals("devTesting")) {
      try {
        inputStream = new FileInputStream(args[1]);
      } catch(FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    } else {
      inputStream = System.in;
    }
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskD solver = new TaskD();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskD {
    final int ring = (int) 1e9 + 7;
    int n, inik;
    String s;
    int[][][] state;

    void solve(int testNumber, InputReader in, PrintWriter out) {
        n = in.nextInt();
        s = in.next();
        state = new int[n + 1][n + 1][1 << 16];
        for (int[][] i : state) {
            for (int[] j : i) {
                Arrays.fill(j, -1);
            }
        }
        long ans = 0;
        for (int i = 2; i <= n + 1; ++i) {
            for (int j = 0; j < s.length(); ++j) {
                ans = add(ans, go(i - 1, j, 0));
            }
        }
        out.println(ans);
    }

    long go(int k, int p, int m) {
        if (state[k][p][m] != -1) {
            return state[k][p][m];
        }
        if (k == 0) {
            if ((m & 1) == 0 && Integer.bitCount((m >> 1) + 1) == 1) {
                return 1;
            }
            return 0;
        } else {
            if (p >= s.length()) {
                return 0;
            }
        }
        long ans = 0;
        for (int i = p; i <= s.length() - 1; ++i) {
            int x = Integer.parseInt(s.substring(p, i + 1), 2);
            if (x >= 1 << 16) {
                break;
            }
            ans = add(ans, go(k - 1, i + 1, m | 1 << x));
        }
        state[k][p][m] = (int) ans;
        return ans;
    }

    long add(long a, long b) {
        long ans = (a + b) % ring;
        if (ans < 0) {
            ans += ring;
        }
        return ans;
    }

    int i(long x) {
      return (int) x;
    }

    <T> void heapsort(T[] a, int s, int e) {
      Queue<T> queue = new PriorityQueue<>();
      for (int i = s; i <= e; ++i)
        queue.add(a[i]);
      for (int i = s; i <= e; ++i)
        a[i] = queue.poll();
    }

  }

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

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      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 String nextLine() {
      try {
        return reader.readLine();
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }

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

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

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

    public boolean hasInput() {
      try {
        if (tokenizer != null && tokenizer.hasMoreTokens()) {
          return true;
        }
        reader.mark(1);
        int ch = reader.read();
        if (ch != -1) {
          reader.reset();
          return true;
        }
        return false;
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }

  }
}


import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int s=sc.nextInt();
        int v1=sc.nextInt();
        int v2=sc.nextInt();
        int t1=sc.nextInt();
        int t2=sc.nextInt();
        int first=(s*v1)+(t1*2);
        int second=(s*v2)+(t2*2);
        String rest="Friendship";
        if(first<second){rest="First";}
        else if(first>second){
            rest="Second";
        }
        System.out.println(rest);
  }


public class JavaApplication1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner scanner=new Scanner(System.in);
        int lemon = scanner.nextInt();
        int apple = scanner.nextInt();
        int pear = scanner.nextInt();

         int result=0;

        for(int i=lemon;i>0;i--){
             if(2*i<=apple&&4*i<=pear){
                result=i+(2*i)+(4*i);
                System.out.println(result+"");
                return;
            }

        }

    }


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

public class First {
    private static final Scanner sc = new Scanner(System.in);
    private static final PrintWriter pw = new PrintWriter(System.out);
    private static StringBuffer ans = new StringBuffer();

    public static void main(String[] args) throws Exception {
        int n = sc.nextInt(), s = 0;
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 1; i <= n; i++) {
            a.add(i);
            s += i;
            if (s >= n) break;
        }
        if (s > n) a.remove(new Integer(s - n));
        ans.append(a.size() + "\n");
        for (int x : a) ans.append(x + " ");
        pw.print(ans);
        sc.close();
        pw.close();
    }
}
class Scanner {
    private final BufferedReader br;
    private StringTokenizer st
    public Scanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(in));
        st = new StringTokenizer("");
    }
    public String next() throws IOException {
        if (!st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public void close() throws IOException {
        br.close();
    }
}
class PrintWriter {
    private final BufferedOutputStream pw;
    public PrintWriter(OutputStream out) {
        pw = new BufferedOutputStream(out);
    }
    public void print(Object o) throws IOException {
        pw.write(o.toString().trim().getBytes());
        pw.flush();
    }
    public void close() throws IOException {
        pw.close();
    }
}


// package CodeForces;

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

public class Round608E {

	public static void solve() {
		long n = s.nextLong();
		long k = s.nextLong();
		long ans = Long.max(EvenBs(n, k), OddBs(n, k));
		if(ans == 0) throw null;
		out.println(ans);
	}

	public static long EvenBs(long limit, long k) {
		long start = 1;
		long end = limit/2;
		long ans = 0;
		while(start <= end) {
			long mid = start + (end - start + 1)/2L;
			long value = wt(mid * 2L, limit);
			if(value >= k) {
				ans = mid * 2L;
				start = mid + 1;
			}else {
				end = mid - 1;
			}
		}
		return ans;
	}

	public static long OddBs(long limit, long k) {
		long start = 1;
		long end = limit/2;
		long ans = 0;
		while(start <= end) {
			long mid = start + (end - start + 1)/2L;
			long my_val = mid * 2 - 1;
			long my_even = my_val * 2L;
			long value;
			if(my_even > limit) {
				value = my_val <= limit ? 1 : 0;
			}else {
				value = wt(my_even, limit) + 1;
			}
			if(value >= k) {
				ans = my_val;
				start = mid + 1;
			}else {
				end = mid - 1;
			}
		}
		return ans;
	}

	public static long wt(long x, long limit) {
		if(x%2 != 0) throw null;
		long start = x;
		long ans = 0;
		long pow2 = 2;
		while(start + pow2 - 1 <= limit) {
			ans += pow2;
			start = start * 2L;
			pow2 *= 2L;
		}
		if(limit >= start) ans += (limit - start + 1);
		return ans;
	}

	public static void main(String[] args) {
		new Thread(null, null, "Thread", 1 << 27) {
			public void run() {
				try {
					out = new PrintWriter(new BufferedOutputStream(System.out));
					s = new FastReader(System.in);
					solve();
					out.close();
				} catch (Exception e) {
					e.printStackTrace();
					System.exit(1);
				}
			}
		}.start();
	}

	public static PrintWriter out;
	public static FastReader s;

	public static class FastReader {

		private InputStream stream;
		private byte[] buf = new byte[4096];
		private int curChar, snumChars;

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

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

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int number = 0;
			do {
				number *= 10;
				number += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return number * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			long sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long number = 0;
			do {
				number *= 10L;
				number += (long) (c - '0');
				c = read();
			} while (!isSpaceChar(c));
			return number * sgn;
		}

		public int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = this.nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = this.nextLong();
			}
			return arr;
		}

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

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

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

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

	}

}


import java.util.Scanner;

public class Bug {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int currentNum = 0;
		int sign = 1;
		int answer = 0;
		String exp = input.nextLine();
		exp += '+'; // This allows the program to parse the last number in the expression
		for (int i = 0; i < exp.length(); i++) {
			if (exp.charAt(i) == '+') {
				answer += sign * currentNum;
				sign = 1;
				currentNum = 0;
			} else if (exp.charAt(i) == '-') {
				answer += sign * currentNum;
				sign = -1;
				currentNum = 0;
			}
			// The bug is caused by the lack of this "else" statement. It causes the first
			// digit of the number to be ('+' - '0') or ('-' - '0')
			// else {
			currentNum = currentNum * 10 + (int) (exp.charAt(i) - '0');
			// }
		}
		System.out.println(answer);
	}
}


import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int x = n/2;
        if(x%2==0 && n%2==0)
        {
            System.out.println("0");
        }
        else if(x%2!=0 && n%2!=0)
        {

            System.out.println("0");
        }
        else
        {
             System.out.println("1");
        }

        System.out.println((list.get(0)));

    }
}


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

public class E {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	static final int[] PS = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,
			43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };

	int l, r, p;
	List<Integer> goodAL = new ArrayList<>();

	static int[] toIntArray(List<Integer> a) {
		int[] ret = new int[a.size()];
		int i = 0;
		for (Integer x : a) {
			ret[i++] = x;
		}
		return ret;
	}

	void dfs(int x, int i) {
		if (i == PS.length) {
			return;
		}
		dfs(x, i + 1);
		if (x <= r / PS[i]) {
			int next = x * PS[i];
			goodAL.add(next);
			dfs(next, i);
		}
	}

	void solve() throws IOException {
		l = nextInt();
		r = nextInt();
		p = nextInt();
		goodAL.add(1);
		dfs(1, 0);
		int[] good = toIntArray(goodAL);
		Arrays.sort(good);

		int n = good.length;

		int[] dp = new int[n];
		int oo = Integer.MAX_VALUE / 3;
		Arrays.fill(dp, oo);
		dp[0] = 0;
		for (int x = 2; x <= p; x++) {
			for (int i = 0, j = 0; i < n; i++) {
				long needL = (long) good[i] * x;
				if (needL > r) {
					break;
				}
				while (j < n && good[j] < needL) {
					j++;
				}
				if (j == n || good[j] != needL) {
					continue;
				}
				if (dp[i] + x < p) {
					dp[j] = Math.min(dp[j], dp[i] + 1);
				}
			}
		}

		int ans = 0;

		for (int i = 0; i < n; i++) {
			if (good[i] >= l && dp[i] != oo) {
				ans++;
			}
		}

		out.println(ans);
	}

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

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

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

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

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

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

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


import java.util.*;
import java.util.regex.*;
import java.lang.*;
public class Main{
	public static void main(String[] args)
	{
	Scanner sc=new Scanner(System.in);
	long n=sc.nextLone();
	System.out.println(6+(n)*(n+11)/2);

	}

}


package Div2_470;

import java.util.Scanner;

public class B3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x2 = in.nextInt();
        int n = x2 + 10;
        int prost1[] = new int[n];
        int mas[] = new int[n];
        int df = 0;
        for (int i = 2; i < n; i++) {
            if (mas[i] == 0) {
                for (int j = 2 * i; j < n; j += i) {
                    mas[j] = 1;
                }
                prost1[df++] = i;
            }
        }
        int prost[] = new int[df];
        for (int i = 0; i < df; i++) {
            prost[i] = prost1[i];
        }
        int min = 1_000_000;
        if (x2 < min) {
            min = x2;
        }
        int x1 = 1000_000;
        int uk = 0;
        while (uk < df && prost[uk] < x2) {
            if (x2 % prost[uk] == 0) {
                int po = Math.max(prost[uk], x2 - prost[uk]) + 1;
                if (po < x1) {
                    x1 = po;
                }
            }
            uk++;
        }
        if (x1 < min) {
            min = x1;
        }
        int cur = 0;
        for (int i = x1; i < x2; i++) {
            int iq = (int) Math.sqrt(i);
            int s = 2;
            int gt = 0;
            int yu =0 ;
            while (cur < df && s <= iq) {
                if (i % s == 0) {
                    if (prost[cur] == s) {
                        int po = Math.max(prost[cur], i - prost[cur]) + 1;
                        if (po < min) {
                            min = po;
                        }
                    }
                    yu = s;
                    gt++;
                }
                s++;
                if (s > prost[cur]) {
                    cur++;
                }
            }
            if (gt == 1) {
                int ho = i / yu;
                if (ho % yu != 0) {
                    int po = Math.max(ho, i - ho) + 1;
                    if (po < min) {
                        min = po;
                    }
                }
            }
            cur = 0;
        }
        System.out.println(min);
    }
}


import java.io.BufferedReader;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Stack;
import java.util.StringTokenizer;

public class codeforces2 {

	public static void main(String[] args) throws IOException {
		PrintWriter pw = new PrintWriter(System.out);
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		// String str = br.readLine();
		PriorityQueue<Long> q = new PriorityQueue<Long>();
		StringTokenizer st = new StringTokenizer(br.readLine());
		long x = Long.parseLong(st.nextToken());
		long y = Long.parseLong(st.nextToken());
		long l = Long.parseLong(st.nextToken());
		long r = Long.parseLong(st.nextToken());

		// StringTokenizer st = new StringTokenizer(br.readLine());

		for (int i = 0; i < 64; i++) {
			for (int j = 0; j < 64; j++) {
				long sum = (long) (Math.pow(x, i)) + (long) Math.pow(y, j);
				q.add(sum);
			}
		}
		long temp = l;
		int c = 0;
		long max = 0;
		boolean f=true;
		while (!q.isEmpty()) {
			long curr = q.peek();
			if (curr >= l && curr <= r) {
				//System.out.println(curr);
			/*	if (temp == l&&f) {
					max = Math.max(max, curr - temp);
					f=false;*/
				} else {
					max = Math.max(max, curr - temp - 1);
				}
				temp = curr;
			}
			q.poll();
		}
		max = Math.max(max, r - temp);
		System.out.println(max);

	}
}


//package CodeForces.Round516_div2;

import java.util.Scanner;

/**
 * @Author: tianchengjiang
 * @Date：2018/10/22
 */
public class problemF {
    public static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        while (scanner.hasNext()) {
            long n = scanner.nextLong();
            long l = scanner.nextLong();
            long r = scanner.nextLong();
            long k = scanner.nextLong();
            long maxm = -1;

            long rangeX = r-l+1;
            if(rangeX <=0){
                rangeX += n;
            }
            long rangeY = n-rangeX;
            if(n <= Math.cbrt(k)){
                for(long x=0;x<=rangeX;x++){
                    for(long y=0;y<=rangeY;y++){
                        long temp = k - x - rangeX;
                        if(temp >= 0 && temp %(rangeX+rangeY+x+y) ==0){
                            maxm = Math.max(maxm,x+y);
                        }
                        if( x>0 && temp+1 >=0 && (temp+1)%(rangeX+rangeY+x+y) == 0){
                            maxm = Math.max(maxm,x+y);
                        }
                    }
                }
            }else{
                for(long t=0;t<=k/n;t++){
                    long temp = k - n * t - rangeX;
                    if(temp>=0){
                        if(t == 0 ){
                            if( temp <= rangeX){
                                maxm = Math.max(maxm, temp + rangeY);
                            }
                            if(temp +1<= rangeX){
                                maxm = Math.max(maxm,temp + 1 + rangeY);
                            }
                        }else {
                            long zmin = Math.max(ge(temp - rangeX, t), ge(temp, t + 1));
                            long zmax = Math.min(le(temp, t), le(temp + rangeY, t + 1));
                            if (zmax >= zmin) {
                                maxm = Math.max(maxm, zmax);
                            }
                            temp++;
                            zmin = Math.max(ge(temp - rangeX, t), ge(temp, t + 1));
                            zmax = Math.min(le(temp-1, t), le(temp + rangeY, t + 1));
                            if (zmax >= zmin) {
                                maxm = Math.max(maxm, zmax);
                            }

                        }
                    }
                }
            }
            System.out.println(maxm);
        }
    }

    public static long  ple(long fz, long fm) { // fz >= 0, fm > 0
        return fz / fm;
    }

    public static long pge(long fz, long fm) { //fz >= 0, fm > 0
        return (fz + fm - 1) / fm;
    }

    public static long le (long fz, long fm) {
        return fz >= 0 ? ple(fz, fm) : -pge(-fz, fm); // 别忘了pge(-fz, fm)前面的负号！
    }
    public static long ge(long fz, long fm) {
        return fz >= 0 ? pge(fz, fm) : -ple(-fz, fm);
    }

}


import java.util.*;

public class cf344B{

	public static void main(String args[])
	{

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if((a+b+c)%2 == 1)
		{
			System.out.println("Impossible");
			return;
		}

		for(int i=0; i<=(a/2); i++)
		{
			if((b-i) > 0 && b-i == c-(a-i))
			{
				System.out.println(i+" "+(b-i)+" "+(a-i));
				return;
			}
			else if((c-i)>0 && b-(a-i) == c-i)
			{
				System.out.println((a-i)+" "+(c-i)+" "+i);
				return;
			}

		}

		System.out.println("Impossible");

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class N {
	public static void main(String[] args) throws IOException {
		 BufferedReader x = new BufferedReader(new InputStreamReader(System.in));
	        int b=Integer.parseInt(x.readLine());
	        int c=Integer.parseInt(x.readLine());
	        int d=Integer.parseInt(x.readLine());
	        System.out.println((b>d&&c>d)?d+1:(b==d&&c==d)||(b<=n&&c>=d)?b+1:(b<n&&c<d)?1+b+c-d:(c<=d&&b>=d)?c+1:0);
	}
}