import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { static boolean[] enable = new boolean[40]; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int[] counts = new int[9]; for (char c : sc.next().toCharArray()) { counts[c - '1']++; } calc(Math.min(n, 3), counts, 0); System.out.println(IntStream.range(0, 40).filter(i -> enable[i]).count()); } static void calc(int idx, int[] counts, int value) { if (idx == 0) { enable[value % 40] = true; return; } for (int i = 0; i < 9; i++) { if (counts[i] == 0) { continue; } counts[i]--; calc(idx - 1, counts, value * 10 + i + 1); counts[i]++; } } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }