Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- import java.math.*;
- class Solution {
- public static void main(String args[])
- {
- Scanner in = new Scanner(System.in);
- String w = in.next();
- int n = in.nextInt();
- if (in.hasNextLine())
- {
- in.nextLine();
- }
- int sum=0;
- for (int i = 0; i < n; i++)
- {
- String s = in.nextLine();
- boolean ok = true;
- for(int j = 0; j < w.length(); j++)
- {
- if(countXInString(s, w.charAt(j)) < countXInString(w, w.charAt(j)) )
- {
- ok = false;
- }
- }
- if(ok)
- sum++;
- }
- System.out.println(sum);
- }
- public static int countXInString(String s, char x)
- {
- int res = 0;
- for(int i = 0; i < s.length(); i++)
- {
- if(x <= 'Z')
- {
- if(s.toUpperCase().charAt(i) == x)
- res++;
- }
- else
- {
- if(s.toLowerCase().charAt(i) == x)
- res++;
- }
- }
- return res;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement