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

public class prefixstrings_vd {

	public void solve() throws IOException {
		int n = nextInt();
		String s = next();
		int k = s.length();
		int[] prefix = new int[k];
		for (int i = 1; i < k; i++) {
			int pos = prefix[i - 1];
			while (pos > 0 && s.charAt(i) != s.charAt(pos)) {
				pos = prefix[pos - 1];
			}
			if (s.charAt(i) == s.charAt(pos)) {
				prefix[i] = pos + 1;
			}
		}
		int[] dp = new int[n + 1];
		dp[k] = 1;
		for (int i = k + 1; i <= n; i++) {
			for (int j = 0; j < k; j++) {
				if (prefix[j] == 0)
					dp[i] = (dp[i - j - 1] + dp[i]) % 1000000007;
			}
		}
		out.println(dp[n]);
	}

	final String fileName = "prefixstrings_vd_".split("_")[0];

	public void run() throws IOException {
		br = new BufferedReader(new FileReader(fileName + ".in"));
		out = new PrintWriter(fileName + ".out");
		solve();
		out.close();
		br.close();
	}

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

	BufferedReader br;
	StringTokenizer str;
	PrintWriter out;

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

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

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

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

}
