import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedList;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
StringBuffer sb = new StringBuffer("");
String m = "";
ArrayList<Character> arr;
LinkedList<String> list = new LinkedList<String>();
while (true) {
m = br.readLine();
if ("#".equals(m)) {
break;
}
list.add(m);
}
m="";
while (true) {
m = br.readLine();
if ("#".equals(m)) {
break;
}
arr = new ArrayList<Character>();
for (int i = 0; i < m.length(); i++) {
if (m.charAt(i) >= 'a' && m.charAt(i) <= 'z') {
arr.add(m.charAt(i));
}
}
int counter = 0;
for (int i = 0; i < list.size(); i++) {
String temp = list.get(i);
boolean flag = true;
ArrayList<Character> arr2=new ArrayList<Character>();
for(int j=0;j<arr.size();j++){
arr2.add(arr.get(j));
}
for (int j = 0; j < temp.length(); j++) {
if (!arr2.contains(temp.charAt(j))) {
flag = false;
break;
}else{
arr2.remove(arr2.indexOf(temp.charAt(j)));
}
}
if (flag) {
counter++;
}
}
sb.append(counter).append("\n");
}
System.out.print(sb);
}
}
No comments:
Post a Comment