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

public class prefixstrings_akov {
	FastScanner in;
	PrintWriter out;

	final long mod = (long)1e9 + 7;
	
	public void solve() throws IOException {
		int n = in.nextInt();
		char[] s = in.next().toCharArray();
		int k = s.length;
		boolean[] badPrefix = new boolean[k];
		for (int start = 1; start < k; start++) {
			int i = 0;
			while (start + i < k && s[i] == s[start + i]) {
				badPrefix[start + i] = true;
				i++;
			}
		}
		
		long[] dp = new long[n + 1];
		dp[k] = 1;
		for (int i = k + 1; i <= n; i++) {
			for (int j = 0; j < k; j++) {
				if (!badPrefix[j] && i - j - 1 >= k) {
					dp[i] = (dp[i] + dp[i - j - 1]) % mod;
				}
			}
		}
		out.println(dp[n]);
	}

	public void run() {
		try {
			in = new FastScanner(new File("prefixstrings.in"));
			out = new PrintWriter(new File("prefixstrings.out"));

			solve();

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

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				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());
		}

	}

	public static void main(String[] arg) {
		new prefixstrings_akov().run();
	}
}