private static int countGem(String[] rocks) {

        boolean[][] flags = new boolean[rocks.length][26];
        
        for (int i = 0; i < rocks.length; i++) {
            
            String rock = rocks[i];
            for (int j = 0; j < rock.length(); j++) {
                flags[i][rock.charAt(j) - 'a'] = true;
            }
        }
        
        int ret = 0;
        for (int i = 0; i < flags[0].length; i++) {
            
            boolean allOccur = true;
            for (int j = 0; j < flags.length; j++) {
                
                if(flags[j][i] == false) {
                    allOccur = false;
                }
            }
            if(allOccur) {
                ret ++;
            }
        }
        
        
        return ret;
    }