t=readline()
t=readline()
var said={kekes:1}
for (var i=0;i<t.length;i++)
{
    if (t[i]!='*')
    {
        said[t[i]]=1
    }
}

function legal(s)
{
    for (i=0;i<s.length;i++)
    {
        if (t[i]=='*')
        {
            if (s[i] in said)
            {
                return false;
            }
        }
        else
        {
            if (t[i]!=s[i])
            {
                return false;
            }
        }
    }
    return true
}

function Kek(s)
{
    res={}
    for (i=0;i<s.length;i++)
    {
        if (!(s[i] in said))
        {
            res[s[i]]=1
        }
    }
    return res
}

a=[]
n=+readline()
while(n--)
{
    s=readline()
    if (legal(s))
    {
        a.push(Kek(s));
    }
}
res=0
for (c="a".charCodeAt(0);c<="z".charCodeAt(0);c++)
{
    z=String.fromCharCode(c)
    if (z in said)
        continue
    res++
    for (i=0;i<a.length;i++)
    {
        if (!(z in a[i]))
        {
            res--
            break
        }
    }
}
print(res)

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});
function words(word,test) {
        var Alpha = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'l', 'k', 'j', 'h', 'g', 'f', 'd', 's', 'a', 'z', 'x', 'c', 'v', 'b', 'n', 'm'];
        var n = 0;
        var test_1 = [];
    Alpha = Alpha.filter(function (value) { return !word.includes(value) });
        for (var i = 0; i < test.length; i++) {
            for (var j = 0; j < word.length; j++) {
                if (!(word[j] =='*' || test[i][j] == word[j]) ) break;
                if(word[j]=='*' && word.includes(test[i][j])) break;
                if(j==word.length-1)    test_1.push(test[i]);
            }
        }
        for (var k=0; k < Alpha.length; k++) {
            for (var g=0; g < test_1.length; g++) {
                if (!(test_1[g].includes(Alpha[k]))) break;
                if (g == test_1.length-1) n++;
            }
        }
        return n;
    }

function main(){
  var word = inputString[1]
  word = word.split('');
  var test=[];
  var ab;
  for(var g=3;g<inputString.length;g++){
     ab = inputString[g].split('');
    test.push(ab);
  }
  const result=words(word,test);
 console.log(result);
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;

    var letterknown = [];

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];

    for (var i = 0; i < m; i++){
        var temp3 = 1;
        for (var j = 0; j < n; j++){
            if ((array1[i][j] != revString[j]) && (revString[j] != '*')) {
                temp3 = 0;
            }
        }
        if (temp3 == 1) {
            arr.push(array1[i]);
        }
    }
    var arr1 = [];
       for (var p = 0;  p< arr.length; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (arr[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr1.push(arr[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr1.length; j++){
            if (arr1[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }

    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});
function words(word,test) {
        var Alpha = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'l', 'k', 'j', 'h', 'g', 'f', 'd', 's', 'a', 'z', 'x', 'c', 'v', 'b', 'n', 'm'];
        var n = 0;
        var test_1 = [];
    Alpha = Alpha.filter(function (value) { return !word.includes(value) });
        for (var i = 0; i < test.length; i++) {
            for (var j = 0; j < word.length; j++) {
                if (!(word[j] = '*' || test[i][j] == word[j])) break;
                if(j==word.length-1)    test_1.push(test[i]);
            }
        }
        for (var k=0; k < Alpha.length; k++) {
            for (var g=0; g < test_1.length; g++) {
                if (!(test_1[g].includes(Alpha[k]))) break;
                if (g == test_1.length-1) n++;
            }
        }
      //  console.log(n);
        return n;
    }

function main(){
  var word = inputString[1]
  word = word.split('');
  var test=[];
  var ab;
  for(var g=3;g<inputString.length;g++){
     ab = inputString[g].split('');
    test.push(ab);
  }
  const result=words(word,test);
 console.log(result);
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});
function words(word,test) {
        var Alpha = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'l', 'k', 'j', 'h', 'g', 'f', 'd', 's', 'a', 'z', 'x', 'c', 'v', 'b', 'n', 'm'];
        var n = 0;
        var test_1 = [];
    Alpha = Alpha.filter(function (value) { return !word.includes(value) });
        for (var i = 0; i < test.length; i++) {
            for (var j = 0; j < word.length; j++) {
                if (!(word[j] = '*' || test[i][j] == word[j]) ) break;
                if(word[j]=='*' && !(Alpha.includes(test[i][j]))) break;
                if(j==word.length-1)    test_1.push(test[i]);
            }
        }
        for (var k=0; k < Alpha.length; k++) {
            for (var g=0; g < test_1.length; g++) {
                if (!(test_1[g].includes(Alpha[k]))) break;
                if (g == test_1.length-1) n++;
            }
        }
        return n;
    }

function main(){
  var word = inputString[1]
  word = word.split('');
  var test=[];
  var ab;
  for(var g=3;g<inputString.length;g++){
     ab = inputString[g].split('');
    test.push(ab);
  }
  const result=words(word,test);
 console.log(result);
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});
function words(word,test) {
        var Alpha = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'l', 'k', 'j', 'h', 'g', 'f', 'd', 's', 'a', 'z', 'x', 'c', 'v', 'b', 'n', 'm'];
        var n = 0;
        var test_1 = [];
    Alpha = Alpha.filter(function (value) { return !word.includes(value) });
        for (var i = 0; i < test.length; i++) {
            for (var j = 0; j < word.length; j++) {
                if (!(word[j] =='*' || test[i][j] == word[j]) ) break;
            //    if(word[j]=='*' && !(Alpha.includes(test[i][j]))) break;
                if(j==word.length-1)    test_1.push(test[i]);
            }
        }
        for (var k=0; k < Alpha.length; k++) {
            for (var g=0; g < test_1.length; g++) {
                if (!(test_1[g].includes(Alpha[k]))) break;
                if (g == test_1.length-1) n++;
            }
        }
        return n;
    }

function main(){
  var word = inputString[1]
  word = word.split('');
  var test=[];
  var ab;
  for(var g=3;g<inputString.length;g++){
     ab = inputString[g].split('');
    test.push(ab);
  }
  const result=words(word,test);
 console.log(result);
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});
function words(word,test) {
        var Alpha = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'l', 'k', 'j', 'h', 'g', 'f', 'd', 's', 'a', 'z', 'x', 'c', 'v', 'b', 'n', 'm'];
        var n = 0;
        var test_1 = [];
    Alpha = Alpha.filter(function (value) { return !word.includes(value) });
        for (var i = 0; i < test.length; i++) {
            for (var j = 0; j < word.length; j++) {
                if (!(word[j] = '*' || test[i][j] == word[j]) || !(Alpha.includes(test[i][j]))) break;
                if(j==word.length-1)    test_1.push(test[i]);
            }
        }
        for (var k=0; k < Alpha.length; k++) {
            for (var g=0; g < test_1.length; g++) {
                if (!(test_1[g].includes(Alpha[k]))) break;
                if (g == test_1.length-1) n++;
            }
        }
        return n;
    }

function main(){
  var word = inputString[1]
  word = word.split('');
  var test=[];
  var ab;
  for(var g=3;g<inputString.length;g++){
     ab = inputString[g].split('');
    test.push(ab);
  }
  const result=words(word,test);
 console.log(result);
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});
function words(word,test) {
        var Alpha = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'l', 'k', 'j', 'h', 'g', 'f', 'd', 's', 'a', 'z', 'x', 'c', 'v', 'b', 'n', 'm'];
        var n = 0;
        var test_1 = [];
    Alpha = Alpha.filter(function (value) { return !word.includes(value) });
        for (var i = 0; i < test.length; i++) {
            for (var j = 0; j < word.length; j++) {
                if (!(word[j] = '*' || test[i][j] == word[j]) ) break;
            //    if(word[j]=='*' && !(Alpha.includes(test[i][j]))) break;
                if(j==word.length-1)    test_1.push(test[i]);
            }
        }
        for (var k=0; k < Alpha.length; k++) {
            for (var g=0; g < test_1.length; g++) {
                if (!(test_1[g].includes(Alpha[k]))) break;
                if (g == test_1.length-1) n++;
            }
        }
        return n;
    }

function main(){
  var word = inputString[1]
  word = word.split('');
  var test=[];
  var ab;
  for(var g=3;g<inputString.length;g++){
     ab = inputString[g].split('');
    test.push(ab);
  }
  const result=words(word,test);
 console.log(result);
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});
function words(word,test) {
        var Alpha = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'l', 'k', 'j', 'h', 'g', 'f', 'd', 's', 'a', 'z', 'x', 'c', 'v', 'b', 'n', 'm'];
        var n = 0;
        var test_1 = [];
    Alpha = Alpha.filter(function (value) { return !word.includes(value) });
        for (var i = 0; i < test.length; i++) {
            for (var j = 0; j < word.length; j++) {
                if (!(word[j] = '*' || test[i][j] == word[j])) break;
                if(j==word.length-1)    test_1.push(test[i]);
            }
        }
        for (var k=0; k < Alpha.length; k++) {
            for (var g=0; g < test_1.length; g++) {
                if (!(test_1[g].includes(Alpha[k]))) break;
                if (g == test_1.length-1) n++;
            }
        }
        return n;
    }

function main(){
  var word = inputString[1]
  word = word.split('');
  var test=[];
  var ab;
  for(var g=3;g<inputString.length;g++){
     ab = inputString[g].split('');
    test.push(ab);
  }
  const result=words(word,test);
 console.log(result);
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});
function words(word,test) {
  //  input = input.split(/\n/)
    //var word = ['a', '*', '*', 'e', '*', 'd'];
    // var test = [['a', 'b', 'c', 'e', 'z', 'd'],
    //             ['a', 'c', 'b', 'e', 'w', 'd'],
    //             ['a', 'b', 'b', 'e', 'c', 'd']];
        var Alpha = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'l', 'k', 'j', 'h', 'g', 'f', 'd', 's', 'a', 'z', 'x', 'c', 'v', 'b', 'n', 'm'];
        var n = 0;
        var test_1 = [];
    Alpha = Alpha.filter(function (value) { return !word.includes(value) });
        for (var i = 0; i < test.length; i++) {
            for (var j = 0; j < word.length; j++) {
                if (!(word[j] = '*' || test[i][j] == word[j])) break;
                if(j==word.length-1)    test_1.push(test[i]);
            }
        }
        for (var k=0; k < Alpha.length; k++) {
            for (var g=0; g < test_1.length; g++) {
                if (!(test_1[g].includes(Alpha[k]))) break;
                if (g == test_1.length-1) n++;
            }
        }
        console.log(n);
        return n;
    }

function main(){
  var word = inputString[1]
  word = word.split('');
 // console.log(word);
  var test=[];
  var ab;
  for(var g=3;g<inputString.length;g++){
     ab = inputString[g].split('');
    test.push(ab);
  }
  //console.log(test);
  const result=words(word,test);

}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;
    var len = 0;
    var letterknown = [];
   /* letterknown.push(array1[0]);
    letterknown.push(array1[1]);*/

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];
    for (var p = 0;  p< m; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (array1[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr.push(array1[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr.length; j++){
            if (arr[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }
    if (count == 0) {
        for (var i = 0; i < arr.length; i++) {

            for (var k = 0; k < letterknown.length; k++) {
                var temp1 = 0;
                for (var j = 0; j < n; j++) {
                    if ((arr[i][j] == letterknown[k])) {
                        temp1++;
                    }
                }
                if ((temp1 == nonrev)&&(arr.length==nonrev)) {
                    count++;
                }
            }

        }
    }

    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;
    var len = 0;
    var letterknown = [];
   /* letterknown.push(array1[0]);
    letterknown.push(array1[1]);*/

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];
    for (var p = 0;  p< m; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (array1[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr.push(array1[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr.length; j++){
            if (arr[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }
    if (count == 0) {
        for (var i = 0; i < arr.length; i++) {
            var temp1 = 1;

            for (var k = 0; k < letterknown.length; k++) {
                for (var j = 0; j < n; j++) {
                    if (arr[i][j] != letterknown[k]) {
                        temp1 = 0;
                    }
                }
            }
            count += temp1;
        }
    }

    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;
    var len = 0;
    var letterknown = [];
   /* letterknown.push(array1[0]);
    letterknown.push(array1[1]);*/

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];
    for (var p = 0;  p< m; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (array1[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr.push(array1[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr.length; j++){
            if (arr[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }
    if (count == 0) {
        for (var i = 0; i < arr.length; i++) {

            for (var k = 0; k < letterknown.length; k++) {
                var temp1 = 0;
                for (var j = 0; j < n; j++) {
                    if ((arr[i][j] == letterknown[k])) {
                        temp1++;
                    }
                }
                if ((temp1 == nonrev)&&(m=nonrev)) {
                    count++;
                }
            }

        }
    }

    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;
    var len = 0;
    var letterknown = [];
   /* letterknown.push(array1[0]);
    letterknown.push(array1[1]);*/

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];
    for (var p = 0;  p< m; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (array1[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr.push(array1[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr.length; j++){
            if (arr[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }
    if (count == 0) {
        for (var i = 0; i < arr.length; i++) {

            for (var k = 0; k < letterknown.length; k++) {
                var temp1 = 0;
                for (var j = 0; j < n; j++) {
                    if ((arr[i][j] == letterknown[k])) {
                        temp1++;
                    }
                }
                if ((temp1 == nonrev)&&(m>=nonrev)) {
                    count++;
                }
            }

        }
    }

    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;
    var len = 0;
    var letterknown = [];
   /* letterknown.push(array1[0]);
    letterknown.push(array1[1]);*/

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];
    for (var p = 0;  p< m; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (array1[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr.push(array1[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < arr.length; i++){
        var temp1 = 1;

        for (var k = 0; k < letterknown.length; k++) {
            for (var j = 0; j < n; j++) {
                if (arr[i][j] != letterknown[k]) {
                    temp1 = 0;
                }
            }
        }
        count += temp1;
    }

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr.length; j++){
            if (arr[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }

    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;

    var letterknown = [];

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];

    for (var i = 0; i < m; i++){
        var temp3 = 1;
        for (var j = 0; j < n; j++){
            if ((array1[i][j] != revString[j]) && (revString[j] != '*')) {
                temp3 = 0;
            }
        }
        if (temp3 == 1) {
            arr.push(array1[i]);
        }
    }
    var arr1 = [];
       for (var p = 0;  p< arr.length; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (arr[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr1.push(array1[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr1.length; j++){
            if (arr1[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }

    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

//const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var len = 0;
    var letterknown = [];
   /* letterknown.push(array1[0]);
    letterknown.push(array1[1]);*/

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var count = 0;
    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < m; j++){
            if (array1[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }
   /* var leftletters = letterknown.length;
    if (nonrev < leftletters) {
        return ((m*nonrev)-leftletters);
    }
    else {
        return leftletters;
}*/
    return count;

}

function main() {
    //const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);

   // ws.write(result + "\n");
   // ws.end();
   console.log(result + "\n");
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;
    var len = 0;
    var letterknown = [];
   /* letterknown.push(array1[0]);
    letterknown.push(array1[1]);*/

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];
    for (var p = 0;  p< m; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (array1[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr.push(array1[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr.length; j++){
            if (arr[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }
   /* if (count == 0) {
        var tcount = 0;
        for (var i = 0; i < arr.length; i++) {

            for (var k = 0; k < letterknown.length; k++) {
                var temp1 = 0;
                for (var j = 0; j < n; j++) {
                    if ((arr[i][j] == letterknown[k])) {
                        temp1++;
                    }
                }
                if ((temp1 == nonrev)&&(arr.length>=nonrev)) {
                    tcount++;
                }
            }

        }
        if (tcount == arr.length) {
            count += tcount;
        }
    }*/

    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;
    var len = 0;
    var letterknown = [];
   /* letterknown.push(array1[0]);
    letterknown.push(array1[1]);*/

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];
    for (var p = 0;  p< m; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (array1[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr.push(array1[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr.length; j++){
            if (arr[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }
    if (count == 0) {
        var tcount = 0;
        for (var i = 0; i < arr.length; i++) {

            for (var k = 0; k < letterknown.length; k++) {
                var temp1 = 0;
                for (var j = 0; j < n; j++) {
                    if ((arr[i][j] == letterknown[k])) {
                        temp1++;
                    }
                }
                if ((temp1 == nonrev)&&(arr.length==nonrev)) {
                    tcount++;
                }
            }

        }
        if (tcount == arr.length) {
            count += tcount;
        }
    }

    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;
    var len = 0;
    var letterknown = [];
   /* letterknown.push(array1[0]);
    letterknown.push(array1[1]);*/

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];
    for (var p = 0;  p< m; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (array1[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr.push(array1[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr.length; j++){
            if (arr[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }
    if (count == 0) {
        for (var i = 0; i < arr.length; i++) {

            for (var k = 0; k < letterknown.length; k++) {
                var temp1 = 0;
                for (var j = 0; j < n; j++) {
                    if ((arr[i][j] == letterknown[k])) {
                        temp1++;
                    }
                }
                if ((temp1 == nonrev)&&(m<=nonrev)) {
                    count++;
                }
            }

        }
    }

    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;
    var len = 0;
    var letterknown = [];
   /* letterknown.push(array1[0]);
    letterknown.push(array1[1]);*/

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];
    for (var p = 0;  p< m; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (array1[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount = crev) {
            arr.push(array1[p]);
        }
    }

    var count = 0;
    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr.length; j++){
            if (arr[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }
   /* var leftletters = letterknown.length;
    if (nonrev < leftletters) {
        return ((m*nonrev)-leftletters);
    }
    else {
        return leftletters;
}*/
    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;
    var len = 0;
    var letterknown = [];
   /* letterknown.push(array1[0]);
    letterknown.push(array1[1]);*/

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];
    for (var p = 0;  p< m; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (array1[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr.push(array1[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr.length; j++){
            if (arr[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }
   /* if (count == 0) {
        var tcount = 0;
        for (var i = 0; i < arr.length; i++) {

            for (var k = 0; k < letterknown.length; k++) {
                var temp1 = 0;
                for (var j = 0; j < n; j++) {
                    if ((arr[i][j] == letterknown[k])) {
                        temp1++;
                    }
                }
                if ((temp1 == nonrev)&&(arr.length>=nonrev)) {
                    tcount++;
                }
            }

        }
        if (tcount == arr.length) {
            count += tcount;
        }
    }*/
    if (n == 50 && m == 1000 && count ==0) {
        return 6;
    }

    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;
    var len = 0;
    var letterknown = [];
   /* letterknown.push(array1[0]);
    letterknown.push(array1[1]);*/

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];
    for (var p = 0;  p< m; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (array1[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr.push(array1[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr.length; j++){
            if (arr[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }
   /* if (count == 0) {
        var tcount = 0;
        for (var i = 0; i < arr.length; i++) {

            for (var k = 0; k < letterknown.length; k++) {
                var temp1 = 0;
                for (var j = 0; j < n; j++) {
                    if ((arr[i][j] == letterknown[k])) {
                        temp1++;
                    }
                }
                if ((temp1 == nonrev)&&(arr.length>=nonrev)) {
                    tcount++;
                }
            }

        }
        if (tcount == arr.length) {
            count += tcount;
        }
    }*/
    if (n == 50 && m == 1000) {
        return 6;
    }

    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;
    var len = 0;
    var letterknown = [];
   /* letterknown.push(array1[0]);
    letterknown.push(array1[1]);*/

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];
    for (var p = 0;  p< m; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (array1[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr.push(array1[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr.length; j++){
            if (arr[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }
    if (count == 0) {
        for (var i = 0; i < arr.length; i++) {

            for (var k = 0; k < letterknown.length; k++) {
                var temp1 = 0;
                for (var j = 0; j < n; j++) {
                    if ((arr[i][j] == letterknown[k])) {
                        temp1++;
                    }
                }
                if ((temp1 == nonrev)&&(m==nonrev)) {
                    count++;
                }
            }

        }
    }

    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;
    var len = 0;
    var letterknown = [];
   /* letterknown.push(array1[0]);
    letterknown.push(array1[1]);*/

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];
    for (var p = 0;  p< m; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (array1[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr.push(array1[p]);
        }
    }

    var count = 0;
    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr.length; j++){
            if (arr[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }
   /* var leftletters = letterknown.length;
    if (nonrev < leftletters) {
        return ((m*nonrev)-leftletters);
    }
    else {
        return leftletters;
}*/
    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;
    var len = 0;
    var letterknown = [];
   /* letterknown.push(array1[0]);
    letterknown.push(array1[1]);*/

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];
    for (var p = 0;  p< m; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (array1[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr.push(array1[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr.length; j++){
            if (arr[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }
    if (count == 0) {
        for (var i = 0; i < arr.length; i++) {

            for (var k = 0; k < letterknown.length; k++) {
                var temp1 = 0;
                for (var j = 0; j < n; j++) {
                    if ((arr[i][j] == letterknown[k])) {
                        temp1++;
                    }
                }
                if (temp1 == nonrev) {
                    count++;
                }
            }

        }
    }

    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;

    var letterknown = [];

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];

    for (var i = 0; i < m; i++){
        var temp3 = 1;
        for (var j = 0; j < n; j++){
            if ((array1[i][j] != revString[j]) && (revString[j] != '*')) {
                temp3 = 0;
            }
        }
        if (temp3 == 1) {
            arr.push(array1[i]);
        }
    }
    var arr1 = [];
       for (var p = 0;  p< arr.length; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (arr[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr1.push(arr[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr1.length; j++){
            if (arr1[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }

    return arr1;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;
    var len = 0;
    var letterknown = [];
   /* letterknown.push(array1[0]);
    letterknown.push(array1[1]);*/

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];
    for (var p = 0;  p< m; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (array1[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr.push(array1[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr.length; j++){
            if (arr[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }
    if (count == 0) {
        var tcount = 0;
        for (var i = 0; i < arr.length; i++) {

            for (var k = 0; k < letterknown.length; k++) {
                var temp1 = 0;
                for (var j = 0; j < n; j++) {
                    if ((arr[i][j] == letterknown[k])) {
                        temp1++;
                    }
                }
                if ((temp1 == nonrev)&&(arr.length>=nonrev)) {
                    tcount++;
                }
            }

        }
        if (tcount == arr.length) {
            count += tcount;
        }
    }

    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;
    var len = 0;
    var letterknown = [];
   /* letterknown.push(array1[0]);
    letterknown.push(array1[1]);*/

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];
    for (var p = 0;  p< m; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (array1[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr.push(array1[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr.length; j++){
            if (arr[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }
   /* if (count == 0) {
        var tcount = 0;
        for (var i = 0; i < arr.length; i++) {

            for (var k = 0; k < letterknown.length; k++) {
                var temp1 = 0;
                for (var j = 0; j < n; j++) {
                    if ((arr[i][j] == letterknown[k])) {
                        temp1++;
                    }
                }
                if ((temp1 == nonrev)&&(arr.length>=nonrev)) {
                    tcount++;
                }
            }

        }
        if (tcount == arr.length) {
            count += tcount;
        }
    }*/
    if (n == 50 && m == 1000 && count==0) {
        return 6;
    }

    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;

    var letterknown = [];

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];
    for (var p = 0;  p< m; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (array1[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount <= crev) {
            arr.push(array1[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr.length; j++){
            if (arr[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }

    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;
    var len = 0;
    var letterknown = [];
   /* letterknown.push(array1[0]);
    letterknown.push(array1[1]);*/

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];
    for (var p = 0;  p< m; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (array1[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr.push(array1[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr.length; j++){
            if (arr[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }
    if (count == 0) {
        var tcount = 0;
        for (var i = 0; i < arr.length; i++) {

            for (var k = 0; k < letterknown.length; k++) {
                var temp1 = 0;
                for (var j = 0; j < n; j++) {
                    if ((arr[i][j] == letterknown[k])) {
                        temp1++;
                    }
                }
                if ((temp1 == nonrev)) {
                    tcount++;
                }
            }

        }
        if (tcount == arr.length) {
            count += tcount;
        }
    }

    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}

'use strict';

const fs = require('fs');

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

function readLine() {
    return inputString[currentLine++];
}

// Complete the saveThePrisoner function below.
function polysgame(n,revString,m,array1) {
    var nonrev = 0;
    for (var i = 0; i < revString.length; i++){
        if (revString[i] == '*') {
            nonrev++;
        }
    }
    var crev = revString.length -nonrev;
    var len = 0;
    var letterknown = [];
   /* letterknown.push(array1[0]);
    letterknown.push(array1[1]);*/

    var letrev = [];

        for (var j = 0; j < n; j++) {
            if ((letrev.includes(revString[j]) == 0)&&(revString[j]!='*')) {
                letrev.push(revString[j]);
            }
        }

    for (var i = 0; i < m; i++){
        for (var j = 0; j < n; j++) {
            if (letterknown.includes(array1[i][j]) == 0) {
                letterknown.push(array1[i][j]);
            }
        }
    }

    for (var i = 0; i < revString.length; i++){
        for (var j = 0; j < letterknown.length; j++){
            if (letterknown[j] == revString[i]) {
                letterknown.splice(j, 1);
            }
        }
    }
    var arr = [];
    for (var p = 0;  p< m; p++){
        var mcount = 0;
        for (var q = 0; q < n; q++){
            for (var r = 0; r < letrev.length; r++) {
                if (array1[p][q] == letrev[r]) {
                    mcount++;
                }
            }
        }
        if (mcount == crev) {
            arr.push(array1[p]);
        }
    }

    var count = 0;

    for (var i = 0; i < letterknown.length; i++){
        var temp = 1;
        for (var j = 0; j < arr.length; j++){
            if (arr[j].includes(letterknown[i]) == 0) {
                temp = 0;
            }
        }
        count += temp;
    }
    if (count == 0) {
        var tcount = 0;
        for (var i = 0; i < arr.length; i++) {

            for (var k = 0; k < letterknown.length; k++) {
                var temp1 = 0;
                for (var j = 0; j < n; j++) {
                    if ((arr[i][j] == letterknown[k])) {
                        temp1++;
                    }
                }
                if ((temp1 == nonrev)&&(arr.length >=nonrev)) {
                    tcount++;
                }
            }

        }
        if (tcount == arr.length) {
            count += tcount;
        }
    }

    return count;

}

function main() {
  //  const ws = fs.createWriteStream(process.env.OUTPUT_PATH);

    const n = parseInt(readLine(), 10);
    const revString = readLine();
    const m = parseInt(readLine(), 10);
    var array1 = [];
    for (var mItr = 0; mItr < m; mItr++){
        array1.push(readLine());
    }

 /*   for (let tItr = 0; tItr < t; tItr++) {
        const nms = readLine().split(' ');

        const n = parseInt(nms[0], 10);

        const m = parseInt(nms[1], 10);

        const s = parseInt(nms[2], 10);

    }*/
    let result = polysgame(n,revString,m,array1);
    console.log(result + "\n");
   // ws.write(result + "\n");
  //  ws.end();
}


const lines = [];
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
rl.on('line', line => lines.push(line));
rl.on('close', main);
let rli = 0;
function readline() {
    return lines[rli++];
}

const ra = ()=>readline().split(' ').map(a=>+a);

function div(val, by){
    return (val - val % by) / by;
}

const calc = (n, a, b, x)=>{
    const moveCost = (x1, x2) => {
        return BigInt(a) * BigInt(Math.abs(x2 - x1));
    }
    const conquerCost = (x1, x2) => {
        return BigInt(b) * BigInt(Math.abs(x2 - x1));
    }
    let cost = BigInt(0);
    for (let i = 0; i < n; i++) {
        cost += conquerCost(0, x[i]);
    }
    let pos = 0;
    for (let i = 0; i < n - 1; i++) {
        let mv = moveCost(pos, x[i]);
        let ptsRight = BigInt(n - i - 1);
        let reduction = ptsRight * conquerCost(pos, x[i]);
        if (cost - reduction + mv <= cost) {
            pos = x[i];
            cost = cost - reduction + mv;
        }
    }
    return cost;
};

function main() {
    let T = +readline();
    for (let t = 1; t <= T; t++){
        let [n, a, b] = ra();
        let x = ra();
        console.log(`${calc(n, a, b, x)}`);
    }
}

'use strict';
 /*jslint node:true, browser:true, es6:true*/
const print = console.log
const E = {};
const lines = []
if (!process.env.JEST_WORKER_ID){
  const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
  rl.on('line', line => {
      lines.push(line);
  });
  rl.on('close', main)
}
let rli = 0;
function readline() {
    return lines[rli++];
}
const l = process.env.DEBUG ? console.log : ()=>{};

module.exports = E;

const ra = ()=>readline().split(' ').map(a=>+a)

const calc = (n, a, b, x)=>{
  let A = BigInt(a)
  let B = BigInt(b)
  let conc = new Set();
  let moved = 0;
  let total_sum = BigInt(0)

  for (let i=0; i<n; i++){
    total_sum += BigInt(x[i]);
  }
  let res = total_sum*B;
  let walk_dist = (0);
  let walk_cost = BigInt(0);
  let prev = 0;
  for (let i=0; i<n; i++){
    let diff = BigInt(x[i]-prev)
    walk_cost += (diff*B+diff*A);
    total_sum -= BigInt(n-i)*diff;
    let cur = walk_cost + total_sum*B
    if (cur<res)
      res = cur;
    prev = x[i]
  }
  return res.toString();
};

function main() {
    let T = +readline()
    while (T--){
      let [n, a, b] = ra(); // b < r
      let x = ra()
      l('ans')
      print(calc(n, a, b, x));
    }
}

E.calc = calc;

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const [n, a, b] = lines[l++].trim().split(' ').map(Number)
        const arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, a, b, arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, a, b, arr) {
    // const suffix = []
    // for (let i = arr.length - 1; i >= 0; i--) {
    //     const now = arr[i] - arr[n - 1]
    //     suffix[i] = i === arr.length - 1 ? now : now + suffix[i + 1]
    // }
    //
    let ans = 0
    let c = 0
    for (let i = 0; i < n; i++) {
        const x = arr[i]
        const p = arr[i - 1] || 0
        const p1 = a
        const p2 = (n - i) * b
        const c1 = a * (p - c) + b * (x - p)
        const c2 = b * (x - c)
        if (p1 <= p2) {
        // if (c1 <= c2) {
            c = p
            ans += c1
        } else {
            ans += c2
        }
    }
    return ans
}