// Working program using BufferedReader
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.*;
import java.util.stream.Collectors;

public class Codeforces_round605 {

    static int mindistance(int a,int b,int c) {
        int res = 0;
        if(a == b) {
            if (c != a) {
                if(c-1 != a) return 2*(c-a-2);
                else return 0;
            }
            else return 0;

        }
        else if(b == c) {
            if (c != a) {
                if(c-1 != a) return 2*(c-a-2);
                else return 0;
            }
            else return 0;
        }
        else {
            return b-a-1 + c-a-2 + c-1-b;
        }
    }
    static String corr_seq(String s) {
        char[] ss = s.toCharArray();
        HashMap<Character,Integer> counts = new HashMap<Character, Integer>();
        counts.put('L',0);
        counts.put('R',0);
        counts.put('U',0);
        counts.put('D',0);
        for(char c:ss) {
            counts.put(c,counts.get(c)+1);
        }
        int L = Math.min(counts.get('L'),counts.get('R'));
        int U = Math.min(counts.get('U'),counts.get('D'));
        if (L ==0 && U>1)  {
            U = 1;
        }
        if (U ==0 && L>1)  {
            L = 1;
        }
        StringBuffer res = new StringBuffer();
        for(int i =0; i < U; i++) {
            res.append("U");
        }
        for(int i =0; i < L; i++) {
            res.append("L");
        }
        for(int i =0; i < U; i++) {
            res.append("D");
        }
        for(int i =0; i < L; i++) {
            res.append("R");
        }
        return res.toString();
    }
    static long numofsubstrings(String s, HashSet<Character> allowed,int n,int k) {
        int i=0,j=0;
        long res = 0;
        char[] ss = s.toCharArray();
        while (i <n) {
            j = i;
            while( j < n && allowed.contains(ss[j])) {
                j++;
            }
            res += ((j-i)*(j-i+1) )/2;
            i = j+1;
        }
        return res;

    }
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(
                new InputStreamReader(System.in));

        String[] frisltine = br.readLine().split(" ");
        int n = Integer.parseInt(frisltine[0]);
        int k = Integer.parseInt(frisltine[1]);

            String s = br.readLine();
        HashSet<Character> allowed = new HashSet<Character>();
        String[] all = br.readLine().split(" ");
        for (String ss: all) {
            if (ss.length() > 0) {
            char c =  ss.charAt(0);
            allowed.add(c); }
        }
            long res = numofsubstrings(s,allowed,n,k);
           System.out.println(res);

    }

}


// Working program using BufferedReader
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.*;
import java.util.stream.Collectors;

public class Codeforces_round605 {

    static int mindistance(int a,int b,int c) {
        int res = 0;
        if(a == b) {
            if (c != a) {
                if(c-1 != a) return 2*(c-a-2);
                else return 0;
            }
            else return 0;

        }
        else if(b == c) {
            if (c != a) {
                if(c-1 != a) return 2*(c-a-2);
                else return 0;
            }
            else return 0;
        }
        else {
            return b-a-1 + c-a-2 + c-1-b;
        }
    }
    static String corr_seq(String s) {
        char[] ss = s.toCharArray();
        HashMap<Character,Integer> counts = new HashMap<Character, Integer>();
        counts.put('L',0);
        counts.put('R',0);
        counts.put('U',0);
        counts.put('D',0);
        for(char c:ss) {
            counts.put(c,counts.get(c)+1);
        }
        int L = Math.min(counts.get('L'),counts.get('R'));
        int U = Math.min(counts.get('U'),counts.get('D'));
        if (L ==0 && U>1)  {
            U = 1;
        }
        if (U ==0 && L>1)  {
            L = 1;
        }
        StringBuffer res = new StringBuffer();
        for(int i =0; i < U; i++) {
            res.append("U");
        }
        for(int i =0; i < L; i++) {
            res.append("L");
        }
        for(int i =0; i < U; i++) {
            res.append("D");
        }
        for(int i =0; i < L; i++) {
            res.append("R");
        }
        return res.toString();
    }
    static long numofsubstrings(String s, HashSet<Character> allowed,int n,int k) {
        long i=0,j=0;
        long res = 0;
        char[] ss = s.toCharArray();
        while (i <n) {
            j = i;
            while( j < n && allowed.contains(ss[(int)j])) {
                j++;
            }
            res += ((j-i)*(j-i+1) )/2;
            i = j+1;
        }
        return res;

    }
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(
                new InputStreamReader(System.in));

        String[] frisltine = br.readLine().split(" ");
        int n = Integer.parseInt(frisltine[0]);
        int k = Integer.parseInt(frisltine[1]);

            String s = br.readLine();
        HashSet<Character> allowed = new HashSet<Character>();
        String[] all = br.readLine().split(" ");
        for (String ss: all) {
            if (ss.length() > 0) {
            char c =  ss.charAt(0);
            allowed.add(c); }
        }
            long res = numofsubstrings(s,allowed,n,k);
           System.out.println(res);

    }

}


// Working program using BufferedReader
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.*;
import java.util.stream.Collectors;

public class Codeforces_round605 {

    static int mindistance(int a,int b,int c) {
        int res = 0;
        if(a == b) {
            if (c != a) {
                if(c-1 != a) return 2*(c-a-2);
                else return 0;
            }
            else return 0;

        }
        else if(b == c) {
            if (c != a) {
                if(c-1 != a) return 2*(c-a-2);
                else return 0;
            }
            else return 0;
        }
        else {
            return b-a-1 + c-a-2 + c-1-b;
        }
    }
    static String corr_seq(String s) {
        char[] ss = s.toCharArray();
        HashMap<Character,Integer> counts = new HashMap<Character, Integer>();
        counts.put('L',0);
        counts.put('R',0);
        counts.put('U',0);
        counts.put('D',0);
        for(char c:ss) {
            counts.put(c,counts.get(c)+1);
        }
        int L = Math.min(counts.get('L'),counts.get('R'));
        int U = Math.min(counts.get('U'),counts.get('D'));
        if (L ==0 && U>1)  {
            U = 1;
        }
        if (U ==0 && L>1)  {
            L = 1;
        }
        StringBuffer res = new StringBuffer();
        for(int i =0; i < U; i++) {
            res.append("U");
        }
        for(int i =0; i < L; i++) {
            res.append("L");
        }
        for(int i =0; i < U; i++) {
            res.append("D");
        }
        for(int i =0; i < L; i++) {
            res.append("R");
        }
        return res.toString();
    }
    static int numofsubstrings(String s, HashSet<Character> allowed,int n,int k) {
        int i=0,j=0;
        int res = 0;
        char[] ss = s.toCharArray();
        while (i <n) {
            j = i;
            while( j < n && allowed.contains(ss[j])) {
                j++;
            }
            res += ((j-i)*(j-i+1) )/2;
            i = j+1;
        }
        return res;

    }
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(
                new InputStreamReader(System.in));

        String[] frisltine = br.readLine().split(" ");
        int n = Integer.parseInt(frisltine[0]);
        int k = Integer.parseInt(frisltine[1]);

            String s = br.readLine();
        HashSet<Character> allowed = new HashSet<Character>();
        String[] all = br.readLine().split(" ");
        for (String ss: all) {
            if (ss.length() > 0) {
            char c =  ss.charAt(0);
            allowed.add(c); }
        }
            int res = numofsubstrings(s,allowed,n,k);
           System.out.println(res);

    }

}


/*Author: Sarthak Srivastava, BITS-Pilani*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import java.math.*;
public class div3c{
/*********************************************Constants******************************************/
static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static long mod=(long)1e9+7;
static long mod1=998244353;
static boolean sieve[];
static ArrayList<Integer> primes;
static long factorial[],invFactorial[];
static ArrayList<Integer> graph[];
static int pptr=0;
static String st[];
/****************************************Solutions Begins***************************************/
public static void main(String args[]) throws Exception{

    nl();

       int s = pi();
       int ac = pi();
       nl();
       String str = ps();
       HashSet<String> hs = new HashSet<>();
       nl();
       for(int i = 0; i<ac;i++)
       {
           hs.add(ps());

       }
       int ans = 0;
       int j = 0 ;
       for(int i = 0; i<str.length();i++)
       {
           char ch = str.charAt(i);
           String tmp = "" + ch;
           if(hs.contains(tmp))
           {
                j++;

           }
           else
           {
            ans += (j * (j + 1))/2;
            j = 0;
           }
       }
       ans += (j * (j + 1))/2;
       System.out.println(ans);

/****************************************Solutions Ends**************************************************/
    out.flush();
    out.close();
}

/****************************************Template Begins************************************************/
static void nl() throws Exception{
    pptr=0;
    st=br.readLine().split(" ");
}
static void nls() throws Exception{
    pptr=0;
    st=br.readLine().split("");
}
static int pi(){
    return Integer.parseInt(st[pptr++]);
}
static long pl(){
    return Long.parseLong(st[pptr++]);
}
static double pd(){
    return Double.parseDouble(st[pptr++]);
}
static String ps(){
    return st[pptr++];
}
/***************************************Precision Printing**********************************************/
static void printPrecision(double d){
    DecimalFormat ft = new DecimalFormat("0.000000000000");
    out.print(ft.format(d));
}
/**************************************Bit Manipulation**************************************************/
static void printMask(long mask){
    System.out.println(Long.toBinaryString(mask));
}
static int countBit(long mask){
    int ans=0;
    while(mask!=0){
        mask&=(mask-1);
        ans++;
    }
    return ans;
}
/******************************************Graph*********************************************************/
static void Makegraph(int n){
    graph=new ArrayList[n];
    for(int i=0;i<n;i++){
        graph[i]=new ArrayList<>();
    }
}
static void addEdge(int a,int b){
    graph[a].add(b);
}
// static void addEdge(int a,int b,int c){
//     graph[a].add(new Pair(b,c));
// }
/*********************************************PAIR********************************************************/
static class Pair implements Comparable<Pair> {
    int u;
    int v;
    int index=-1;
    public Pair(int u, int v) {
        this.u = u;
        this.v = v;
    }
    public int hashCode() {
        int hu = (int) (u ^ (u >>> 32));
        int hv = (int) (v ^ (v >>> 32));
        return 31 * hu + hv;
    }
    public boolean equals(Object o) {
        Pair other = (Pair) o;
        return u == other.u && v == other.v;
    }
    public int compareTo(Pair other) {
        if(index!=other.index)
            return Long.compare(index, other.index);
        return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
    }
    public String toString() {
        return "[u=" + u + ", v=" + v + "]";
    }
}
/******************************************Long Pair*******************************************************/
static class Pairl implements Comparable<Pairl> {
        long u;
        long v;
        int index=-1;
        public Pairl(long u, long v) {
            this.u = u;
            this.v = v;
        }
        public int hashCode() {
            int hu = (int) (u ^ (u >>> 32));
            int hv = (int) (v ^ (v >>> 32));
            return 31 * hu + hv;
        }
        public boolean equals(Object o) {
            Pairl other = (Pairl) o;
            return u == other.u && v == other.v;
        }
        public int compareTo(Pairl other) {
            if(index!=other.index)
                return Long.compare(index, other.index);
            return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
        }
        public String toString() {
            return "[u=" + u + ", v=" + v + "]";
        }
    }
/*****************************************DEBUG***********************************************************/
public static void debug(Object... o){
    System.out.println(Arrays.deepToString(o));
}
/************************************MODULAR EXPONENTIATION***********************************************/
static long modulo(long a,long b,long c){
    long x=1;
    long y=a%c;
    while(b > 0){
        if(b%2 == 1){
            x=(x*y)%c;
        }
        y = (y*y)%c; // squaring the base
        b /= 2;
    }
    return  x%c;
}
/********************************************GCD**********************************************************/
static long gcd(long x, long y){
    if(x==0)
        return y;
    if(y==0)
        return x;
    long r=0, a, b;
    a = (x > y) ? x : y; // a is greater number
    b = (x < y) ? x : y; // b is smaller number
    r = b;
    while(a % b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}
/******************************************SIEVE**********************************************************/
static void sieveMake(int n){
    sieve=new boolean[n];
    Arrays.fill(sieve,true);
    sieve[0]=false;
    sieve[1]=false;
    for(int i=2;i*i<n;i++){
        if(sieve[i]){
            for(int j=i*i;j<n;j+=i){
                sieve[j]=false;
            }
        }
    }
    primes=new ArrayList<Integer>();
    for(int i=0;i<n;i++){
        if(sieve[i]){
            primes.add(i);
        }
    }
}
/********************************************End***********************************************************/
}


/*Author: Sarthak Srivastava, BITS-Pilani*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import java.math.*;
public class div3c{
/*********************************************Constants******************************************/
static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static long mod=(long)1e9+7;
static long mod1=998244353;
static boolean sieve[];
static ArrayList<Integer> primes;
static long factorial[],invFactorial[];
static ArrayList<Integer> graph[];
static int pptr=0;
static String st[];
/****************************************Solutions Begins***************************************/
public static void main(String args[]) throws Exception{

       nl();
       int s = pi();
       int ac = pi();
       nl();
       String str = ps();
       HashSet<String> hs = new HashSet<>();
       nl();
       for(int i = 0; i<ac;i++)
       {
           hs.add(ps());

       }
       long ans = 0;
       int j = 0 ;
       for(int i = 0; i<str.length();i++)
       {
           char ch = str.charAt(i);
           String tmp = "" + ch;
           if(hs.contains(tmp))
           {
                j++;

           }
           else
           {
            ans += (j * (j + 1))/2;
            j = 0;
           }
       }
       if(j>0)
       ans += (j * (j + 1))/2;
       System.out.println(ans);

/****************************************Solutions Ends**************************************************/
    out.flush();
    out.close();
}

/****************************************Template Begins************************************************/
static void nl() throws Exception{
    pptr=0;
    st=br.readLine().split(" ");
}
static void nls() throws Exception{
    pptr=0;
    st=br.readLine().split("");
}
static int pi(){
    return Integer.parseInt(st[pptr++]);
}
static long pl(){
    return Long.parseLong(st[pptr++]);
}
static double pd(){
    return Double.parseDouble(st[pptr++]);
}
static String ps(){
    return st[pptr++];
}
/***************************************Precision Printing**********************************************/
static void printPrecision(double d){
    DecimalFormat ft = new DecimalFormat("0.000000000000");
    out.print(ft.format(d));
}
/**************************************Bit Manipulation**************************************************/
static void printMask(long mask){
    System.out.println(Long.toBinaryString(mask));
}
static int countBit(long mask){
    int ans=0;
    while(mask!=0){
        mask&=(mask-1);
        ans++;
    }
    return ans;
}
/******************************************Graph*********************************************************/
static void Makegraph(int n){
    graph=new ArrayList[n];
    for(int i=0;i<n;i++){
        graph[i]=new ArrayList<>();
    }
}
static void addEdge(int a,int b){
    graph[a].add(b);
}
// static void addEdge(int a,int b,int c){
//     graph[a].add(new Pair(b,c));
// }
/*********************************************PAIR********************************************************/
static class Pair implements Comparable<Pair> {
    int u;
    int v;
    int index=-1;
    public Pair(int u, int v) {
        this.u = u;
        this.v = v;
    }
    public int hashCode() {
        int hu = (int) (u ^ (u >>> 32));
        int hv = (int) (v ^ (v >>> 32));
        return 31 * hu + hv;
    }
    public boolean equals(Object o) {
        Pair other = (Pair) o;
        return u == other.u && v == other.v;
    }
    public int compareTo(Pair other) {
        if(index!=other.index)
            return Long.compare(index, other.index);
        return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
    }
    public String toString() {
        return "[u=" + u + ", v=" + v + "]";
    }
}
/******************************************Long Pair*******************************************************/
static class Pairl implements Comparable<Pairl> {
        long u;
        long v;
        int index=-1;
        public Pairl(long u, long v) {
            this.u = u;
            this.v = v;
        }
        public int hashCode() {
            int hu = (int) (u ^ (u >>> 32));
            int hv = (int) (v ^ (v >>> 32));
            return 31 * hu + hv;
        }
        public boolean equals(Object o) {
            Pairl other = (Pairl) o;
            return u == other.u && v == other.v;
        }
        public int compareTo(Pairl other) {
            if(index!=other.index)
                return Long.compare(index, other.index);
            return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
        }
        public String toString() {
            return "[u=" + u + ", v=" + v + "]";
        }
    }
/*****************************************DEBUG***********************************************************/
public static void debug(Object... o){
    System.out.println(Arrays.deepToString(o));
}
/************************************MODULAR EXPONENTIATION***********************************************/
static long modulo(long a,long b,long c){
    long x=1;
    long y=a%c;
    while(b > 0){
        if(b%2 == 1){
            x=(x*y)%c;
        }
        y = (y*y)%c; // squaring the base
        b /= 2;
    }
    return  x%c;
}
/********************************************GCD**********************************************************/
static long gcd(long x, long y){
    if(x==0)
        return y;
    if(y==0)
        return x;
    long r=0, a, b;
    a = (x > y) ? x : y; // a is greater number
    b = (x < y) ? x : y; // b is smaller number
    r = b;
    while(a % b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}
/******************************************SIEVE**********************************************************/
static void sieveMake(int n){
    sieve=new boolean[n];
    Arrays.fill(sieve,true);
    sieve[0]=false;
    sieve[1]=false;
    for(int i=2;i*i<n;i++){
        if(sieve[i]){
            for(int j=i*i;j<n;j+=i){
                sieve[j]=false;
            }
        }
    }
    primes=new ArrayList<Integer>();
    for(int i=0;i<n;i++){
        if(sieve[i]){
            primes.add(i);
        }
    }
}
/********************************************End***********************************************************/
}


/*Author: Sarthak Srivastava, BITS-Pilani*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import java.math.*;
public class div3c{
/*********************************************Constants******************************************/
static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static long mod=(long)1e9+7;
static long mod1=998244353;
static boolean sieve[];
static ArrayList<Integer> primes;
static long factorial[],invFactorial[];
static ArrayList<Integer> graph[];
static int pptr=0;
static String st[];
/****************************************Solutions Begins***************************************/
public static void main(String args[]) throws Exception{

       nl();
       int s = pi();
       int ac = pi();
       nl();
       String str = ps();
       HashSet<String> hs = new HashSet<>();
       nl();
       for(int i = 0; i<ac;i++)
       {
           hs.add(ps());

       }
       long ans = 0;
       int j = 0 ;
       for(int i = 0; i<str.length();i++)
       {
           char ch = str.charAt(i);
           String tmp = "" + ch;
           if(hs.contains(tmp))
           {
                j++;

           }
           else
           {
            ans += (j * (j + 1))/2;
            j = 0;
           }
       }
       ans += (j * (j + 1))/2;
       System.out.println(ans);

/****************************************Solutions Ends**************************************************/
    out.flush();
    out.close();
}

/****************************************Template Begins************************************************/
static void nl() throws Exception{
    pptr=0;
    st=br.readLine().split(" ");
}
static void nls() throws Exception{
    pptr=0;
    st=br.readLine().split("");
}
static int pi(){
    return Integer.parseInt(st[pptr++]);
}
static long pl(){
    return Long.parseLong(st[pptr++]);
}
static double pd(){
    return Double.parseDouble(st[pptr++]);
}
static String ps(){
    return st[pptr++];
}
/***************************************Precision Printing**********************************************/
static void printPrecision(double d){
    DecimalFormat ft = new DecimalFormat("0.000000000000");
    out.print(ft.format(d));
}
/**************************************Bit Manipulation**************************************************/
static void printMask(long mask){
    System.out.println(Long.toBinaryString(mask));
}
static int countBit(long mask){
    int ans=0;
    while(mask!=0){
        mask&=(mask-1);
        ans++;
    }
    return ans;
}
/******************************************Graph*********************************************************/
static void Makegraph(int n){
    graph=new ArrayList[n];
    for(int i=0;i<n;i++){
        graph[i]=new ArrayList<>();
    }
}
static void addEdge(int a,int b){
    graph[a].add(b);
}
// static void addEdge(int a,int b,int c){
//     graph[a].add(new Pair(b,c));
// }
/*********************************************PAIR********************************************************/
static class Pair implements Comparable<Pair> {
    int u;
    int v;
    int index=-1;
    public Pair(int u, int v) {
        this.u = u;
        this.v = v;
    }
    public int hashCode() {
        int hu = (int) (u ^ (u >>> 32));
        int hv = (int) (v ^ (v >>> 32));
        return 31 * hu + hv;
    }
    public boolean equals(Object o) {
        Pair other = (Pair) o;
        return u == other.u && v == other.v;
    }
    public int compareTo(Pair other) {
        if(index!=other.index)
            return Long.compare(index, other.index);
        return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
    }
    public String toString() {
        return "[u=" + u + ", v=" + v + "]";
    }
}
/******************************************Long Pair*******************************************************/
static class Pairl implements Comparable<Pairl> {
        long u;
        long v;
        int index=-1;
        public Pairl(long u, long v) {
            this.u = u;
            this.v = v;
        }
        public int hashCode() {
            int hu = (int) (u ^ (u >>> 32));
            int hv = (int) (v ^ (v >>> 32));
            return 31 * hu + hv;
        }
        public boolean equals(Object o) {
            Pairl other = (Pairl) o;
            return u == other.u && v == other.v;
        }
        public int compareTo(Pairl other) {
            if(index!=other.index)
                return Long.compare(index, other.index);
            return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
        }
        public String toString() {
            return "[u=" + u + ", v=" + v + "]";
        }
    }
/*****************************************DEBUG***********************************************************/
public static void debug(Object... o){
    System.out.println(Arrays.deepToString(o));
}
/************************************MODULAR EXPONENTIATION***********************************************/
static long modulo(long a,long b,long c){
    long x=1;
    long y=a%c;
    while(b > 0){
        if(b%2 == 1){
            x=(x*y)%c;
        }
        y = (y*y)%c; // squaring the base
        b /= 2;
    }
    return  x%c;
}
/********************************************GCD**********************************************************/
static long gcd(long x, long y){
    if(x==0)
        return y;
    if(y==0)
        return x;
    long r=0, a, b;
    a = (x > y) ? x : y; // a is greater number
    b = (x < y) ? x : y; // b is smaller number
    r = b;
    while(a % b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}
/******************************************SIEVE**********************************************************/
static void sieveMake(int n){
    sieve=new boolean[n];
    Arrays.fill(sieve,true);
    sieve[0]=false;
    sieve[1]=false;
    for(int i=2;i*i<n;i++){
        if(sieve[i]){
            for(int j=i*i;j<n;j+=i){
                sieve[j]=false;
            }
        }
    }
    primes=new ArrayList<Integer>();
    for(int i=0;i<n;i++){
        if(sieve[i]){
            primes.add(i);
        }
    }
}
/********************************************End***********************************************************/
}


/*Author: Sarthak Srivastava, BITS-Pilani*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import java.math.*;
public class div3c{
/*********************************************Constants******************************************/
static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static long mod=(long)1e9+7;
static long mod1=998244353;
static boolean sieve[];
static ArrayList<Integer> primes;
static long factorial[],invFactorial[];
static ArrayList<Integer> graph[];
static int pptr=0;
static String st[];
/****************************************Solutions Begins***************************************/
public static void main(String args[]) throws Exception{

       nl();
       int s = pi();
       int ac = pi();
       nl();
       String str = ps();
       HashSet<String> hs = new HashSet<>();
       nl();
       for(int i = 0; i<ac;i++)
       {
           hs.add(ps());

       }
       long ans = 0;
       long j = 0 ;
       for(int i = 0; i<str.length();i++)
       {
           char ch = str.charAt(i);
           String tmp = "" + ch;
           if(hs.contains(tmp))
           {
                j++;

           }
           else
           {
            ans += (j * (j + 1))/2;
            j = 0;
           }
       }
       ans += (j * (j + 1))/2;
       System.out.println(ans);

/****************************************Solutions Ends**************************************************/
    out.flush();
    out.close();
}

/****************************************Template Begins************************************************/
static void nl() throws Exception{
    pptr=0;
    st=br.readLine().split(" ");
}
static void nls() throws Exception{
    pptr=0;
    st=br.readLine().split("");
}
static int pi(){
    return Integer.parseInt(st[pptr++]);
}
static long pl(){
    return Long.parseLong(st[pptr++]);
}
static double pd(){
    return Double.parseDouble(st[pptr++]);
}
static String ps(){
    return st[pptr++];
}
/***************************************Precision Printing**********************************************/
static void printPrecision(double d){
    DecimalFormat ft = new DecimalFormat("0.000000000000");
    out.print(ft.format(d));
}
/**************************************Bit Manipulation**************************************************/
static void printMask(long mask){
    System.out.println(Long.toBinaryString(mask));
}
static int countBit(long mask){
    int ans=0;
    while(mask!=0){
        mask&=(mask-1);
        ans++;
    }
    return ans;
}
/******************************************Graph*********************************************************/
static void Makegraph(int n){
    graph=new ArrayList[n];
    for(int i=0;i<n;i++){
        graph[i]=new ArrayList<>();
    }
}
static void addEdge(int a,int b){
    graph[a].add(b);
}
// static void addEdge(int a,int b,int c){
//     graph[a].add(new Pair(b,c));
// }
/*********************************************PAIR********************************************************/
static class Pair implements Comparable<Pair> {
    int u;
    int v;
    int index=-1;
    public Pair(int u, int v) {
        this.u = u;
        this.v = v;
    }
    public int hashCode() {
        int hu = (int) (u ^ (u >>> 32));
        int hv = (int) (v ^ (v >>> 32));
        return 31 * hu + hv;
    }
    public boolean equals(Object o) {
        Pair other = (Pair) o;
        return u == other.u && v == other.v;
    }
    public int compareTo(Pair other) {
        if(index!=other.index)
            return Long.compare(index, other.index);
        return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
    }
    public String toString() {
        return "[u=" + u + ", v=" + v + "]";
    }
}
/******************************************Long Pair*******************************************************/
static class Pairl implements Comparable<Pairl> {
        long u;
        long v;
        int index=-1;
        public Pairl(long u, long v) {
            this.u = u;
            this.v = v;
        }
        public int hashCode() {
            int hu = (int) (u ^ (u >>> 32));
            int hv = (int) (v ^ (v >>> 32));
            return 31 * hu + hv;
        }
        public boolean equals(Object o) {
            Pairl other = (Pairl) o;
            return u == other.u && v == other.v;
        }
        public int compareTo(Pairl other) {
            if(index!=other.index)
                return Long.compare(index, other.index);
            return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
        }
        public String toString() {
            return "[u=" + u + ", v=" + v + "]";
        }
    }
/*****************************************DEBUG***********************************************************/
public static void debug(Object... o){
    System.out.println(Arrays.deepToString(o));
}
/************************************MODULAR EXPONENTIATION***********************************************/
static long modulo(long a,long b,long c){
    long x=1;
    long y=a%c;
    while(b > 0){
        if(b%2 == 1){
            x=(x*y)%c;
        }
        y = (y*y)%c; // squaring the base
        b /= 2;
    }
    return  x%c;
}
/********************************************GCD**********************************************************/
static long gcd(long x, long y){
    if(x==0)
        return y;
    if(y==0)
        return x;
    long r=0, a, b;
    a = (x > y) ? x : y; // a is greater number
    b = (x < y) ? x : y; // b is smaller number
    r = b;
    while(a % b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}
/******************************************SIEVE**********************************************************/
static void sieveMake(int n){
    sieve=new boolean[n];
    Arrays.fill(sieve,true);
    sieve[0]=false;
    sieve[1]=false;
    for(int i=2;i*i<n;i++){
        if(sieve[i]){
            for(int j=i*i;j<n;j+=i){
                sieve[j]=false;
            }
        }
    }
    primes=new ArrayList<Integer>();
    for(int i=0;i<n;i++){
        if(sieve[i]){
            primes.add(i);
        }
    }
}
/********************************************End***********************************************************/
}


	import java.io.BufferedReader;
	import java.util.ArrayList;
	import java.util.Arrays;
	import java.util.Collections;
	import java.util.HashMap;
	import java.util.HashSet;
	import java.util.List;
	import java.util.Map;
	import java.io.IOException;
	import java.io.InputStreamReader;
	import java.util.Scanner;
	import java.util.Set;
	import java.util.StringTokenizer;

	public class ForLooops {
		 static class FastReader
		    {
		        BufferedReader br;
		        StringTokenizer st;

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

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

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

				public Character charAt(int i) {
					// TODO Auto-generated method stub
					return null;
				}
		    }

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

		/**
		 * @param args
		 * @throws IOException
		 */
		 static int m =(int) (1e9+7);
		 static long mod(long x) {

			 return ((x%m+m)%m);
		 }
		 static long add(long x,long y) {
			 return mod((mod(x)+mod(y)));
		 }
		 static long mul(long x,long y) {
			 return mod((mod(x)*mod(y)));
		 }

		public static void main(String[] args)throws IOException  {
			FastReader s=new FastReader();
			int n = s.nextInt();
			int k = s.nextInt();
			String se =s.next();

			Set<Character> l = new HashSet<>();
			long c=0;
			for(int i=0;i<k;i++) {
				char ca = s.next().charAt(0);
				l.add(ca);
			}

			for(int i=0;i<se.length();i++) {

				int j =i;

				while(j<se.length() && l.contains(se.charAt(j))) j++;
				c=(long)(c+(j-i)*(j-i+1)/2);

				i=j;

			}
			System.out.println(c);

		}
	}


	import java.io.BufferedReader;
	import java.util.ArrayList;
	import java.util.Arrays;
	import java.util.Collections;
	import java.util.HashMap;
	import java.util.HashSet;
	import java.util.List;
	import java.util.Map;
	import java.io.IOException;
	import java.io.InputStreamReader;
	import java.util.Scanner;
	import java.util.Set;
	import java.util.StringTokenizer;

	public class ForLooops {
		 static class FastReader
		    {
		        BufferedReader br;
		        StringTokenizer st;

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

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

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

				public Character charAt(int i) {
					// TODO Auto-generated method stub
					return null;
				}
		    }

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

		/**
		 * @param args
		 * @throws IOException
		 */
		 static int m =(int) (1e9+7);
		 static long mod(long x) {

			 return ((x%m+m)%m);
		 }
		 static long add(long x,long y) {
			 return mod((mod(x)+mod(y)));
		 }
		 static long mul(long x,long y) {
			 return mod((mod(x)*mod(y)));
		 }

		public static void main(String[] args)throws IOException  {
			FastReader s=new FastReader();
			int n = s.nextInt();
			int k = s.nextInt();
			String se =s.next();

			Set<Character> l = new HashSet<>();
			long c=0;
			for(int i=0;i<k;i++) {
				char ca = s.next().charAt(0);
				l.add(ca);
			}
			int j =0;
			for(int i=0;i<n	;i++) {
				if(l.contains(se.charAt(i))) j++;
				else{

					c+=j*(j+1)/2;
					j=0;
				}

			}
			c+=j*(j+1)/2;
			System.out.println(c);

		}
	}


	import java.io.BufferedReader;
	import java.util.ArrayList;
	import java.util.Arrays;
	import java.util.Collections;
	import java.util.HashMap;
	import java.util.HashSet;
	import java.util.List;
	import java.util.Map;
	import java.io.IOException;
	import java.io.InputStreamReader;
	import java.util.Scanner;
	import java.util.Set;
	import java.util.StringTokenizer;

	public class ForLooops {
		 static class FastReader
		    {
		        BufferedReader br;
		        StringTokenizer st;

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

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

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

				public Character charAt(int i) {
					// TODO Auto-generated method stub
					return null;
				}
		    }

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

		/**
		 * @param args
		 * @throws IOException
		 */
		 static int m =(int) (1e9+7);
		 static long mod(long x) {

			 return ((x%m+m)%m);
		 }
		 static long add(long x,long y) {
			 return mod((mod(x)+mod(y)));
		 }
		 static long mul(long x,long y) {
			 return mod((mod(x)*mod(y)));
		 }

		public static void main(String[] args)throws IOException  {
			FastReader s=new FastReader();
			int n = s.nextInt();
			int k = s.nextInt();
			String se =s.next();

			Set<Character> l = new HashSet<>();
			long c=0;
			for(int i=0;i<k;i++) {
				char ca = s.next().charAt(0);
				l.add(ca);
			}
			long j =0;
			for(int i=0;i<n	;i++) {
				if(l.contains(se.charAt(i))) j++;
				else{

					c+=j*(j+1)/2;
					j=0;
				}

			}
			c+=j*(j+1)/2;
			System.out.println(c);

		}
	}


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

public class Main {

    void solve () {
        int n =readInt();
        int m=readInt();
        String str=readString();
        char[] ch = new char[m];
        int k=0;
        int [] b= new int[n+1];
        for (int i=0;i<m;i++)
            ch[i]=readString().charAt(0);
        for (int i=0;i<n;i++){
            for (int j=0;j<m;j++){
                if (str.charAt(i)==ch[j]) {
                    b[k] = i + 1;
                    k++;
                    break;
                }
            }
        }
        int g=0;
        int sum=0;
        if (b[1]-b[0]>1){
            sum++;
            g=1;
        }
        for (int i=1;i<=n;i++){
            if (b[i]-b[i-1]!=1 && b[i]-b[i-1]!=0){
                sum+=sum(i-g);
                g=i;
            }
        }
       out.println(sum);
    }
    public static int sum(int n){
        int sum=0;
        for (int i=0;i<n;i++)
            sum+=n-i;
        return sum;
    }

    public static void main(String[] args) {
        new Main().run();

    }
    private void run() {
        try {
            init();
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    private BufferedReader in;
    private StringTokenizer tok = new StringTokenizer("");

    private PrintWriter out;

    private void init() throws FileNotFoundException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

    private String readLine() {
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private String readString() {
        while (!tok.hasMoreTokens()) {
            String nextLine = readLine();
            if (nextLine == null) return null;
            tok = new StringTokenizer(nextLine);
        }

        return tok.nextToken();
    }

    private int readInt() {
        return Integer.parseInt(readString());
    }
    private long readLong(){
        return Long.parseLong(readString());
    }

}


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

public class Main {

    void solve () {
        int n =readInt();
        int m=readInt();
        String str=readString();
        char[] ch = new char[m];
        int k=0;
        int [] b= new int[n+2];
        for (int i=0;i<m;i++)
            ch[i]=readString().charAt(0);
        for (int i=0;i<n;i++){
            for (int j=0;j<m;j++){
                if (str.charAt(i)==ch[j]) {
                    b[k] = i + 1;
                    k++;
                    break;
                }
            }
        }
        int g=0;
        int sum=0;
        if (b[1]-b[0]>1){
            sum++;
            g=1;
        }
        for (int i=1;i<=n+1;i++){
            if (b[i]-b[i-1]!=1 && b[i]-b[i-1]!=0){
                sum+=sum(i-g);
                g=i;
            }
        }
       out.println(sum);
    }
    public static int sum(int n){
        int sum=0;
        for (int i=0;i<n;i++)
            sum+=n-i;
        return sum;
    }

    public static void main(String[] args) {
        new Main().run();

    }
    private void run() {
        try {
            init();
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    private BufferedReader in;
    private StringTokenizer tok = new StringTokenizer("");

    private PrintWriter out;

    private void init() throws FileNotFoundException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

    private String readLine() {
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private String readString() {
        while (!tok.hasMoreTokens()) {
            String nextLine = readLine();
            if (nextLine == null) return null;
            tok = new StringTokenizer(nextLine);
        }

        return tok.nextToken();
    }

    private int readInt() {
        return Integer.parseInt(readString());
    }
    private long readLong(){
        return Long.parseLong(readString());
    }

}


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

public class Main {

    void solve () {
        int n =readInt();
        int m=readInt();
        String str=readString();
        char[] ch = new char[m];
        int k=0;
        int [] b= new int[n+2];
        for (int i=0;i<m;i++)
            ch[i]=readString().charAt(0);
        for (int i=0;i<n;i++){
            for (int j=0;j<m;j++){
                if (str.charAt(i)==ch[j]) {
                    b[k] = i + 1;
                    k++;
                    break;
                }
            }
        }
        int g=0;
        long sum=0;
        if (b[1]-b[0]>1){
            sum++;
            g=1;
        }
        for (int i=1;i<=n+1;i++){
            if (b[i]-b[i-1]!=1 && b[i]-b[i-1]!=0){
                sum+=sum(i-g);
                g=i;
            }
        }
       out.println(sum);
    }
    public static long sum(int n){
        long sum=0;
        for (int i=0;i<n;i++)
            sum+=n-i;
        return sum;
    }

    public static void main(String[] args) {
        new Main().run();

    }
    private void run() {
        try {
            init();
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    private BufferedReader in;
    private StringTokenizer tok = new StringTokenizer("");

    private PrintWriter out;

    private void init() throws FileNotFoundException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

    private String readLine() {
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private String readString() {
        while (!tok.hasMoreTokens()) {
            String nextLine = readLine();
            if (nextLine == null) return null;
            tok = new StringTokenizer(nextLine);
        }

        return tok.nextToken();
    }

    private int readInt() {
        return Integer.parseInt(readString());
    }
    private long readLong(){
        return Long.parseLong(readString());
    }

}


import java.util.Scanner;

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

		int n = stdin.nextInt();
		int k = stdin.nextInt();

		char[] str = new char[n+1];
		char[] in = stdin.next().toCharArray();
		for (int i = 0; i < n; i ++) str[i] = in[i];
		str[n] = '{';

		boolean[] alpha = new boolean[27];

		for (int i = 0; i < k; i ++) alpha[stdin.next().charAt(0) - 'a'] = true;

		int last = 0, sum = 0;
		for (int i = 0; i <= n; i ++) {
			if (alpha[str[i] - 'a']) continue;
			int num = i - last;
			last = i + 1;
			if (num == 0) continue;
			sum += (num * (num + 1)) / 2;
		}

		System.out.println(sum);
	}
}


import java.util.Scanner;

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

		int n = stdin.nextInt();
		int k = stdin.nextInt();

		char[] str = stdin.next().toCharArray();

		boolean[] alpha = new boolean[27];

		for (int i = 0; i < k; i ++) alpha[stdin.next().charAt(0) - 'a'] = true;

		int last = 0;
		long sum = 0;
		for (int i = 0; i < n; i ++) {
			if (alpha[str[i] - 'a']) continue;
			int num = i - last;
			sum += (num * (num + 1) / 2);
			last = i + 1;
		}

		sum += (n - last) * (n - last + 1) / 2;

		System.out.println(sum);
	}
}


import java.util.Scanner;

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

		int n = stdin.nextInt();
		int k = stdin.nextInt();

		char[] str = stdin.next().toCharArray();

		boolean[] alpha = new boolean[27];

		for (int i = 0; i < k; i ++) alpha[stdin.next().charAt(0) - 'a'] = true;

		long last = 0, sum = 0;
		for (int i = 0; i < n; i ++) {
			if (alpha[str[i] - 'a']) continue;
			long num = i - last;
			sum += (num * (num + 1) / 2);
			last = i + 1;
		}

		sum += (n - last) * (n - last + 1) / 2;

		System.out.println(sum);
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class test1 {

	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(br.readLine());
		int n=Integer.parseInt(st.nextToken());
		int k=Integer.parseInt(st.nextToken());
		String s=br.readLine();
		boolean[] arr=new boolean[26];
		st=new StringTokenizer(br.readLine());
		for(int i=0;i<k;i++){
			char c=st.nextToken().charAt(0);
			arr[c-'a']=true;
		}
		long count=0;
		long sum=0;
		for(int i=n-1;i>=0;i--){
			if(arr[s.charAt(i)-'a']){
				count++;
			}
			else{
				sum=sum+(count*(count+1))/2;
				count=0;
			}
		}
		sum=sum+(count*(count+1))/2;
		System.out.println(sum);
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class test1 {

	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(br.readLine());
		int n=Integer.parseInt(st.nextToken());
		int k=Integer.parseInt(st.nextToken());
		String s=br.readLine();
		boolean[] arr=new boolean[26];
		st=new StringTokenizer(br.readLine());
		for(int i=0;i<k;i++){
			char c=st.nextToken().charAt(0);
			arr[c-'a']=true;
		}
		int count=0;
		long sum=0;
		for(int i=n-1;i>=0;i--){
			if(arr[s.charAt(i)-'a']){
				count++;
			}
			else{
				sum=sum+(count*(count+1))/2;
				count=0;
			}
		}
		sum=sum+(count*(count+1))/2;
		System.out.println(sum);
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class test1 {

	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(br.readLine());
		int n=Integer.parseInt(st.nextToken());
		int k=Integer.parseInt(st.nextToken());
		String s=br.readLine();
		boolean[] arr=new boolean[26];
		st=new StringTokenizer(br.readLine());
		for(int i=0;i<k;i++){
			char c=st.nextToken().charAt(0);
			arr[c-'a']=true;
		}
		int count=0;
		int sum=0;
		for(int i=n-1;i>=0;i--){
			if(arr[s.charAt(i)-'a']){
				count++;
			}
			else{
				sum=sum+(count*(count+1))/2;
				count=0;
			}
		}
		sum=sum+(count*(count+1))/2;
		System.out.println(sum);
	}

}


import java.io.*;
import java.util.InputMismatchException;
import java.util.Scanner;
/* * */

public class _605_C implements Runnable{
    public static void main(String[] args) {
	    new Thread(null, new _605_C(),"Main",1<<27).start();
    }
    @Override
    public void run() {
        Scanner scn = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
            long n = scn.nextLong();
            long k = scn.nextLong();
            String s = scn.next();
            scn.nextLine();String avail = scn.nextLine();
            long len = 0;
            long count = 0;
            for(int i = 0; i < n; i++){
                if(avail.contains(""+s.charAt(i))){
                    len++;
                }
                else {
                    count += ((len*(len+1))/2);
                    len = 0;
                }
            }
            count += ((len*(len+1))/2);
            out.println(count);
        out.close();
    }

    //Helper functions
    static int gcd(int a, int b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    static int lcm(int a, int b) {
        return (a*b)/gcd(a, b);
    }

    static boolean checkDistinct(int next){// check all digits are distinct.

        String process = String.valueOf(next);
        for(int i = 0;i < process.length()-1; i++){
            String character = String.valueOf(process.charAt(i));
            if(process.substring(i+1).contains(character)){ return false; }
        }
        return true;
    }

    static int limit = (int) 1e7 + 1;
    static int[] facts = new int[limit];
    static void sieve() {  // Store the minimum prime factors of 1 to LIMIT
        facts[1] = 1;
        for (int i = 2; i < limit; i++) {
            if (i % 2 == 0 && i > 2) {
                facts[i] = 2;
            } else {
                facts[i] = i;
            }
        }
        for (int i = 3; i * i < limit; i++) {
            if (facts[i] == i) {
                for (int j = i * i; j < limit; j += i)
                    if (facts[j] == j)
                        facts[j] = i;
            }
        }
    }
    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

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

        public int read() {
            if (numChars==-1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }

                if(numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt() {
            int c = read();

            while(isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if(c<'0'||c>'9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

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

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString() {
            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 boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

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


import java.io.*;
import java.util.InputMismatchException;
/* * */

public class _605_C implements Runnable{
    public static void main(String[] args) {
	    new Thread(null, new _605_C(),"Main",1<<27).start();
    }
    @Override
    public void run() {
        FastReader fd = new FastReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
            int n = fd.nextInt();
            int k = fd.nextInt();
            String s = fd.next();
            String avail = fd.nextLine();
            int len = 0;
            int count = 0;
            for(int i = 0; i < n; i++){
                if(avail.contains(""+s.charAt(i))){
                    len++;
                }
                else {
                    count += ((len*(len+1))/2);
                    len = 0;
                }
            }
            count += ((len*(len+1))/2);
            out.println(count);
        out.close();
    }

    //Helper functions
    static int gcd(int a, int b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    static int lcm(int a, int b) {
        return (a*b)/gcd(a, b);
    }

    static boolean checkDistinct(int next){// check all digits are distinct.

        String process = String.valueOf(next);
        for(int i = 0;i < process.length()-1; i++){
            String character = String.valueOf(process.charAt(i));
            if(process.substring(i+1).contains(character)){ return false; }
        }
        return true;
    }

    static int limit = (int) 1e7 + 1;
    static int[] facts = new int[limit];
    static void sieve() {  // Store the minimum prime factors of 1 to LIMIT
        facts[1] = 1;
        for (int i = 2; i < limit; i++) {
            if (i % 2 == 0 && i > 2) {
                facts[i] = 2;
            } else {
                facts[i] = i;
            }
        }
        for (int i = 3; i * i < limit; i++) {
            if (facts[i] == i) {
                for (int j = i * i; j < limit; j += i)
                    if (facts[j] == j)
                        facts[j] = i;
            }
        }
    }
    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

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

        public int read() {
            if (numChars==-1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }

                if(numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt() {
            int c = read();

            while(isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if(c<'0'||c>'9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

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

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString() {
            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 boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

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


import java.io.*;
import java.util.InputMismatchException;
import java.util.Scanner;
/* * */

public class _605_C implements Runnable{
    public static void main(String[] args) {
	    new Thread(null, new _605_C(),"Main",1<<27).start();
    }
    @Override
    public void run() {
        Scanner scn = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
            int n = scn.nextInt();
            int k = scn.nextInt();
            String s = scn.next();
            scn.nextLine();String avail = scn.nextLine();
            int len = 0;
            int count = 0;
            for(int i = 0; i < n; i++){
                if(avail.contains(""+s.charAt(i))){
                    len++;
                }
                else {
                    count += ((len*(len+1))/2);
                    len = 0;
                }
            }
            count += ((len*(len+1))/2);
            out.println(count);
        out.close();
    }

    //Helper functions
    static int gcd(int a, int b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    static int lcm(int a, int b) {
        return (a*b)/gcd(a, b);
    }

    static boolean checkDistinct(int next){// check all digits are distinct.

        String process = String.valueOf(next);
        for(int i = 0;i < process.length()-1; i++){
            String character = String.valueOf(process.charAt(i));
            if(process.substring(i+1).contains(character)){ return false; }
        }
        return true;
    }

    static int limit = (int) 1e7 + 1;
    static int[] facts = new int[limit];
    static void sieve() {  // Store the minimum prime factors of 1 to LIMIT
        facts[1] = 1;
        for (int i = 2; i < limit; i++) {
            if (i % 2 == 0 && i > 2) {
                facts[i] = 2;
            } else {
                facts[i] = i;
            }
        }
        for (int i = 3; i * i < limit; i++) {
            if (facts[i] == i) {
                for (int j = i * i; j < limit; j += i)
                    if (facts[j] == j)
                        facts[j] = i;
            }
        }
    }
    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

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

        public int read() {
            if (numChars==-1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }

                if(numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt() {
            int c = read();

            while(isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if(c<'0'||c>'9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

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

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString() {
            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 boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

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


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
import java.util.StringJoiner;
import java.util.stream.IntStream;
//import java.util.Arrays;

public class A {

	public static FastScanner fs = new FastScanner();

	public static void main(String[] args) {
		solve();
	}

	public static void solve(){
		int n = fs.nextInt(), k = fs.nextInt(), var = 0, res = 0;
		String S = fs.next();
		String[] A = new String[k];
		for (int i=0; i<k; i++) A[i]=fs.next();
		for (int i = 0; i < n; i++){
			char x = S.charAt(i);
			boolean found = false;
			for (String j:A){
				if (j.charAt(0) == x){
					found = true;
					break;
				}
			}
			if (found){
				var ++;
			}else {
				res += ((var*(var+1))/2);
				var = 0;
			}
		}
		res += ((var*(var+1))/2);
		System.out.println(res);
	}

	static void array_space(int[] A){
		StringJoiner sj = new StringJoiner(" ");
		IntStream.of(A).forEach(x -> sj.add(String.valueOf(x)));
		System.out.println(sj.toString());
	}

	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
import java.util.StringJoiner;
import java.util.stream.IntStream;
//import java.util.Arrays;

public class A {

	public static FastScanner fs = new FastScanner();

	public static void main(String[] args) {
		solve();
	}

	public static void solve(){
		int n = fs.nextInt(), k = fs.nextInt();
		long var = (long) 0, res = (long) 0;
		String S = fs.next();
		String[] A = new String[k];
		for (int i=0; i<k; i++) A[i]=fs.next();
		for (int i = 0; i < n; i++){
			char x = S.charAt(i);
			boolean found = false;
			for (String j:A){
				if (j.charAt(0) == x){
					found = true;
					break;
				}
			}
			if (found){
				var += (long) 1;
			}else {
				res += (long) ((var*(var+1L))/2L);
				var = (long) 0;
			}
		}
		res += (long) ((var*(var+1L))/2L);
		System.out.println(res);
	}

	static void array_space(int[] A){
		StringJoiner sj = new StringJoiner(" ");
		IntStream.of(A).forEach(x -> sj.add(String.valueOf(x)));
		System.out.println(sj.toString());
	}

	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


/*package whatever //do not write package name here */
import java.util.*;
import java.io.*;

public class DemoClass {
	public static void main (String[] args) {
		Scanner s=new Scanner(System.in);
		int n =s.nextInt();

    int k=s.nextInt();

    //char c[]=new char[k];

    List<Character>l=new ArrayList<>();

   // String s1="";

    String ss=s.next();

    for(int i=0;i<k;i++)

	    l.add(s.next().charAt(0));

	    long c=0;
	long tot=0;

    for(int i=0;i<ss.length();i++){

		        if(l.contains(ss.charAt(i)))

	        c++;
		        else{

         //System.out.println("c="+c);

  tot+=((c*(c+1))/2);

	        c=0;

        }

    }

    if(c!=0)

	    tot+=((c*(c+1))/2);

	    System.out.println(tot);

	}

}


/*package whatever //do not write package name here */
import java.util.*;
import java.io.*;

public class DemoClass {
	public static void main (String[] args) {
		Scanner s=new Scanner(System.in);
		int n =s.nextInt();

    int k=s.nextInt();

    //char c[]=new char[k];

    List<Character>l=new ArrayList<>();

    String s1="";

    String ss=s.next();

    for(int i=0;i<k;i++)

	    l.add(s.next().charAt(0));

	    int c=0;
	long tot=0;

    for(int i=0;i<ss.length();i++){

		        if(l.contains(ss.charAt(i)))

	        c++;
		        else{

         //System.out.println("c="+c);

  tot+=((c*(c+1))/2);
		        c=0;

        }

    }

    if(c!=0)

	    tot+=((c*(c+1))/2);

	    System.out.println(tot);

	}

}


/*package whatever //do not write package name here */
import java.util.*;
import java.io.*;

public class DemoClass {
	public static void main (String[] args) {
		Scanner s=new Scanner(System.in);
		int n =s.nextInt();

		    int k=s.nextInt();
		    //char c[]=new char[k];
		    List<Character>l=new ArrayList<>();
		    String s1="";
		    String ss=s.next();
		    for(int i=0;i<k;i++)
		    l.add(s.next().charAt(0));
		    int c=0,tot=0;
		    for(int i=0;i<ss.length();i++){

		        if(l.contains(ss.charAt(i)))
		        c++;
		        else{
		           //System.out.println("c="+c);
		        tot+=((c*(c+1))/2);
		        c=0;
		        }
		    }
		    if(c!=0)
		    tot+=((c*(c+1))/2);
		    System.out.println(tot);

	}
}


import java.util.Scanner;

/**
 * @author 超厉害的我啊
 * @date 2020/9/6 08:11:49
 */

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        long k=sc.nextLong();
        String s=sc.next();
        int[] arr=new int[26];
        for (int i = 0; i < k; i++) {
            String c=sc.next();
            char ch=c.charAt(0);
            arr[ch-97]++;
        }
        char[] cha=s.toCharArray();
        int p=0;
        long sum=0;
        long ans=0;
        while (p!=n)
        {
            if(arr[cha[p]-97]!=0)
            {
                ans++;
            }else
            {
                sum+=((ans+1)*ans)/2;
                ans=0;
            }
            p++;
        }
        sum+=((ans+1)*ans)/2;
        System.out.println(sum);
    }
}


import java.util.Scanner;

/**
 * @author 超厉害的我啊
 * @date 2020/9/6 08:11:49
 */

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        long k=sc.nextLong();
        String s=sc.next();
        int[] arr=new int[26];
        for (int i = 0; i < k; i++) {
            String c=sc.next();
            char ch=c.charAt(0);
            arr[ch-97]++;
        }
        char[] cha=s.toCharArray();
        int p=0;
        long sum=0;
        int ans=0;
        while (p!=n)
        {
            if(arr[cha[p]-97]!=0)
            {
                ans++;
            }else
            {
                sum+=((ans+1)*ans)/2;
                ans=0;
            }
            p++;
        }
        sum+=((ans+1)*ans)/2;
        System.out.println(sum);
    }
}


import java.util.*;
public class MyClass {
    public static void main(String args[]) {
     Scanner in=new Scanner(System.in);
         int n=in.nextInt();
         int k=in.nextInt();

         char[] s=in.next().toCharArray();
         HashSet<Character> hs=new HashSet<>();
         for(int i=0;i<k;i++)
         {
             hs.add(in.next().charAt(0));
         }

         int count=0;
         ArrayList<Integer> array=new ArrayList<Integer>();
         for(int i=0;i<n;i++)
         {
             if(!hs.contains(s[i])){ array.add(count); count=0; }
             else count++;
         }
         if(count!=0) array.add(count);
         // System.out.println(array);
         int size=array.size();
         long sum=0;
         for(int i=0;i<size;i++)
         { long temp=array.get(i);
             sum+=(temp*(temp+1))/2;
         }
         System.out.println(sum);
     }
}


import java.util.*;
public class MyClass {
    public static void main(String args[]) {
     Scanner in=new Scanner(System.in);
         int n=in.nextInt();
         int k=in.nextInt();

         char[] s=in.next().toCharArray();
         HashSet<Character> hs=new HashSet<>();
         for(int i=0;i<k;i++)
         {
             hs.add(in.next().charAt(0));
         }

         int count=0;
         ArrayList<Integer> array=new ArrayList<Integer>();
         for(int i=0;i<n;i++)
         {
             if(!hs.contains(s[i])){ array.add(count); count=0; }
             else count++;
         }
         if(count!=0) array.add(count);
         // System.out.println(array);
         int size=array.size();
         long sum=0;
         for(int i=0;i<size;i++)
         {int temp=array.get(i);
             sum+=(temp*(temp+1))/2;
         }
         System.out.println(sum);
     }
}


import java.util.*;
public class MyClass {
    public static void main(String args[]) {
     Scanner in=new Scanner(System.in);
         int n=in.nextInt();
         int k=in.nextInt();

         char[] s=in.next().toCharArray();
         HashSet<Character> hs=new HashSet<>();
         for(int i=0;i<k;i++)
         {
             hs.add(in.next().charAt(0));
         }

         int count=0;
         ArrayList<Integer> array=new ArrayList<Integer>();
         for(int i=0;i<n;i++)
         {
             if(!hs.contains(s[i])){ array.add(count); count=0; }
             else count++;
         }
         if(count!=0) array.add(count);
         // System.out.println(array);
         int size=array.size();
         int sum=0;
         for(int i=0;i<size;i++)
         {int temp=array.get(i);
             sum+=(temp*(temp+1))/2;
         }
         System.out.println(sum);
     }
}


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

public class CodingLegacy {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Palindrome solver = new Palindrome();
        int t = 1;

        for(int i=0;i<t;i++) {
            solver.solve(i+1, in, out);
        }
        out.close();
    }

    static class Palindrome {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();

            String s = in.next();
            boolean[] a = new boolean[n];

            for(int i = 0;i<n;i++){
                a[i] = false;
            }

            char[] c = new char[k];
            for(int i = 0;i<k;i++){
                c[i] = in.next().charAt(0);
            }

            int count=0;
            for(int i =0;i<k;i++){
                for (int j = 0;j<n;j++){
                    if(s.charAt(j)==c[i]){
                        a[j] = true;
                        count++;
                    }
                }
            }

//            out.println(Arrays.toString(a));

            if(count==0){
                out.println("0");
                return;
            } else if(count==1){
                out.println("1");
                return;
            }

            int m=-2,p=-1;

            long ans = 0;
            for(int i = 0;i<n;i++){
                if(m<p){
                    if(a[i]){
                        m=i;
                    }
                } else{
                    if(!a[i]){
                        p=i;
                    }
                }

                if(m>=0 && p>=0){
                    ans += (p-m)*(p-m+1)/2;
                    m=-2;
                    p=-1;
                }
            }

            if(p==-1 && m>0){
                ans += (n-m)*(n-m+1)/2;
            }

            out.println(ans);
        }
    }

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

        public static long factorial(int n){
            long fact = 1;
            for(int i=1;i<=n;i++){
                fact *= i;
            }
            return fact;
        }
    }

    static class Characters{
        public static boolean isVovel(char a){
            if(a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u'){
                return true;
            }
            return false;
        }
    }

    static class Binary {
        public static long numberOfBits(long n){
            long count=0;
            while(n>0){
                count++;
                n >>=1;
            }
            return count;
        }

        public static long numberOfSetBits(long n){
            long count = 0;
            int p = 1;
            while (n>0){
                if((n&p) == 1){
                    count++;
                }
                n >>= 1;
            }
            return count;
        }
    }

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

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


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

public class CodingLegacy {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Palindrome solver = new Palindrome();
        int t = 1;

        for(int i=0;i<t;i++) {
            solver.solve(i+1, in, out);
        }
        out.close();
    }

    static class Palindrome {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();

            String s = in.next();
            boolean[] a = new boolean[n];

            for(int i = 0;i<n;i++){
                a[i] = false;
            }

            char[] c = new char[k];
            for(int i = 0;i<k;i++){
                c[i] = in.next().charAt(0);
            }

            int count=0;
            for(int i =0;i<k;i++){
                for (int j = 0;j<n;j++){
                    if(s.charAt(j)==c[i]){
                        a[j] = true;
                        count++;
                    }
                }
            }

//            out.println(Arrays.toString(a));

            if(count<2){
                out.println("0");
                return;
            }

            int m=-2,p=-1;

            int ans = 0;
            for(int i = 0;i<n;i++){
                if(m<p){
                    if(a[i]){
                        m=i;
                    }
                } else{
                    if(!a[i]){
                        p=i;
                    }
                }

                if(m>=0 && p>=0){
                    ans += (p-m)*(p-m+1)/2;
                    m=-2;
                    p=-1;
                }
            }

            if(p==-1 && m>0){
                ans += (n-m)*(n-m+1)/2;
            }

            out.println(ans);
        }
    }

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

        public static long factorial(int n){
            long fact = 1;
            for(int i=1;i<=n;i++){
                fact *= i;
            }
            return fact;
        }
    }

    static class Characters{
        public static boolean isVovel(char a){
            if(a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u'){
                return true;
            }
            return false;
        }
    }

    static class Binary {
        public static long numberOfBits(long n){
            long count=0;
            while(n>0){
                count++;
                n >>=1;
            }
            return count;
        }

        public static long numberOfSetBits(long n){
            long count = 0;
            int p = 1;
            while (n>0){
                if((n&p) == 1){
                    count++;
                }
                n >>= 1;
            }
            return count;
        }
    }

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

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


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

public class CodingLegacy {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Palindrome solver = new Palindrome();
        int t = 1;

        for(int i=0;i<t;i++) {
            solver.solve(i+1, in, out);
        }
        out.close();
    }

    static class Palindrome {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();

            String s = in.next();
            boolean[] a = new boolean[n];

            for(int i = 0;i<n;i++){
                a[i] = false;
            }

            char[] c = new char[k];
            for(int i = 0;i<k;i++){
                c[i] = in.next().charAt(0);
            }

            int count=0;
            for(int i =0;i<k;i++){
                for (int j = 0;j<n;j++){
                    if(s.charAt(j)==c[i]){
                        a[j] = true;
                        count++;
                    }
                }
            }

//            out.println(Arrays.toString(a));

            if(count==0){
                out.println("0");
                return;
            } else if(count==1){
                out.println("1");
                return;
            }

            int m=-2,p=-1;

            long ans = 0;
            for(int i = 0;i<n;i++){
                if(m<p){
                    if(a[i]){
                        m=i;
//                        out.println(m);
                    }
                } else{
                    if(!a[i]){
                        p=i;
                    }
                }

                if(m>=0 && p>=0){
                    ans += (p-m)*(p-m+1)/2;
                    m=-2;
                    p=-1;
                }
            }

            if(p==-1 && m>=0){
                ans += (n-m)*(n-m+1)/2;
            }

            out.println(ans);
        }
    }

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

        public static long factorial(int n){
            long fact = 1;
            for(int i=1;i<=n;i++){
                fact *= i;
            }
            return fact;
        }
    }

    static class Characters{
        public static boolean isVovel(char a){
            if(a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u'){
                return true;
            }
            return false;
        }
    }

    static class Binary {
        public static long numberOfBits(long n){
            long count=0;
            while(n>0){
                count++;
                n >>=1;
            }
            return count;
        }

        public static long numberOfSetBits(long n){
            long count = 0;
            int p = 1;
            while (n>0){
                if((n&p) == 1){
                    count++;
                }
                n >>= 1;
            }
            return count;
        }
    }

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

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


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

public class CodingLegacy {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Palindrome solver = new Palindrome();
        int t = 1;

        for(int i=0;i<t;i++) {
            solver.solve(i+1, in, out);
        }
        out.close();
    }

    static class Palindrome {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();

            String s = in.next();
            boolean[] a = new boolean[n];

            for(int i = 0;i<n;i++){
                a[i] = false;
            }

            char[] c = new char[k];
            for(int i = 0;i<k;i++){
                c[i] = in.next().charAt(0);
            }

            int count=0;
            for(int i =0;i<k;i++){
                for (int j = 0;j<n;j++){
                    if(s.charAt(j)==c[i]){
                        a[j] = true;
                        count++;
                    }
                }
            }

//            out.println(Arrays.toString(a));

            if(count==0){
                out.println("0");
                return;
            } else if(count==1){
                out.println("1");
                return;
            }

            int m=-2,p=-1;

            long ans = 0;
            for(int i = 0;i<n;i++){
                if(m<p){
                    if(a[i]){
                        m=i;
                        out.println(m);
                    }
                } else{
                    if(!a[i]){
                        p=i;
                    }
                }

                if(m>=0 && p>=0){
                    ans += (p-m)*(p-m+1)/2;
                    m=-2;
                    p=-1;
                }
            }

            if(p==-1 && m>=0){
                ans += (n-m)*(n-m+1)/2;
            }

            out.println(ans);
        }
    }

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

        public static long factorial(int n){
            long fact = 1;
            for(int i=1;i<=n;i++){
                fact *= i;
            }
            return fact;
        }
    }

    static class Characters{
        public static boolean isVovel(char a){
            if(a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u'){
                return true;
            }
            return false;
        }
    }

    static class Binary {
        public static long numberOfBits(long n){
            long count=0;
            while(n>0){
                count++;
                n >>=1;
            }
            return count;
        }

        public static long numberOfSetBits(long n){
            long count = 0;
            int p = 1;
            while (n>0){
                if((n&p) == 1){
                    count++;
                }
                n >>= 1;
            }
            return count;
        }
    }

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

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