Problem: Nick likes strings very much, he likes to rotate them, sort them, rearrange characters within a string... Once he wrote a random string of characters a, b, c on a piece of paper and began to perform the following operations: 

  * to take two adjacent characters and replace the second character with the first one, 
  * to take two adjacent characters and replace the first character with the second one 



To understand these actions better, let's take a look at a string «abc». All of the following strings can be obtained by performing one of the described operations on «abc»: «bbc», «abb», «acc». Let's denote the frequency of a character for each of the characters a, b and c as the number of occurrences of this character in the string. For example, for string «abc»: |a| = 1, |b| = 1, |c| = 1, and for string «bbc»: |a| = 0, |b| = 2, |c| = 1. 

While performing the described operations, Nick sometimes got balanced strings. Let's say that a string is balanced, if the frequencies of each character differ by at most 1. That is  - 1 ≤ |a| - |b| ≤ 1,  - 1 ≤ |a| - |c| ≤ 1 и  - 1 ≤ |b| - |c| ≤ 1. 

Would you help Nick find the number of different balanced strings that can be obtained by performing the operations described above, perhaps multiple times, on the given string s. This number should be calculated modulo 51123987.

Input

The first line contains integer n (1 ≤ n ≤ 150) — the length of the given string s. Next line contains the given string s. The initial string can be balanced as well, in this case it should be counted too. The given string s consists only of characters a, b and c.

Output

Output the only number — the number of different balanced strings that can be obtained by performing the described operations, perhaps multiple times, on the given string s, modulo 51123987.

Examples

Input

4
abca


Output

7


Input

4
abbc


Output

3


Input

2
ab


Output

1

Note

In the first sample it is possible to get 51 different strings through the described operations, but only 7 of them are balanced: «abca», «bbca», «bcca», «bcaa», «abcc», «abbc», «aabc». In the second sample: «abbc», «aabc», «abcc». In the third sample there is only one balanced string — «ab» itself.

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;

public class Solution {
	
	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer st;
	
	int mod = 51123987;

	void solve() throws IOException {
		int n = nextInt();
		String s = next();
//		String s = "";
//		Random rnd = new Random();
//		for (int i = 0; i < n; ++i) {
//			s = s + (char)(rnd.nextInt(3) + 'a');
//		}
		int m = (n + 2) / 3;
		int[][][][] d = new int[3][m + 1][m + 1][m + 1];
		int[][][][] pool = new int[3][m + 1][m + 1][m + 1];
		pool[0][0][0][0] = pool[1][0][0][0] = pool[2][0][0][0] = 1;
		for (char c : s.toCharArray()) {
//			System.out.print(c);
			if (c == 'a') {
				for (int v = 0; v <= m; ++v) {
					for (int w = 0; w <= m; ++w) {
						int t = 0;
						for (int u = 0; u <= m; ++u) {
							d[0][u][v][w] = mod(d[0][u][v][w] + t);
							pool[1][u][v][w] = mod(pool[1][u][v][w] + t);
							pool[2][u][v][w] = mod(pool[2][u][v][w] + t);
							t = mod(t + pool[0][u][v][w]);
							pool[0][u][v][w] = 0;
						}
					}
				}
			} else if (c == 'b') {
				for (int u = 0; u <= m; ++u) {
					for (int w = 0; w <= m; ++w) {
						int t = 0;
						for (int v = 0; v <= m; ++v) {
							d[1][u][v][w] = mod(d[1][u][v][w] + t);
							pool[0][u][v][w] = mod(pool[0][u][v][w] + t);
							pool[2][u][v][w] = mod(pool[2][u][v][w] + t);
							t = mod(t + pool[1][u][v][w]);
							pool[1][u][v][w] = 0;
						}
					}
				}
			} else if (c == 'c') {
				for (int u = 0; u <= m; ++u) {
					for (int v = 0; v <= m; ++v) {
						int t = 0;
						for (int w = 0; w <= m; ++w) {
							d[2][u][v][w] = mod(d[2][u][v][w] + t);
							pool[0][u][v][w] = mod(pool[0][u][v][w] + t);
							pool[1][u][v][w] = mod(pool[1][u][v][w] + t);
							t = mod(t + pool[2][u][v][w]);
							pool[2][u][v][w] = 0;
						}
					}
				}
			} else {
				throw new AssertionError();
			}
		}
		int ans = 0;
		for (int u = 0; u <= n; ++u) {
			for (int v = 0; v <= n; ++v) {
				for (int w = 0; w <= n; ++w) {
					if (u + v + w == n && Math.abs(u - v) <= 1 && Math.abs(u - w) <= 1 && Math.abs(v - w) <= 1) {
						for (int t = 0; t < 3; ++t) {
							ans = (ans + d[t][u][v][w]) % mod;
						}
					}
				}
			}
		}
		out.println(ans);
	}

	private int mod(int i) {
		while (i >= mod) {
			i -= mod;
		}
		return i;
	}

	Solution() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		
		eat("");
		
		solve();
		
		in.close();
		out.close();
	}
	
	private void eat(String str) {
		st = new StringTokenizer(str);
	}
	
	String next() throws IOException {
		while (!st.hasMoreTokens()) {
			String line = in.readLine();
			if (line == null) {
				return null;
			}
			eat(line);
		}
		return st.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());
	}

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