public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s;
        while ((s = br.readLine()) != null) {
            StringTokenizer st = new StringTokenizer(s);
            Integer m = new Integer(st.nextToken());
            Integer n = new Integer(st.nextToken());
            oil = new boolean[m][n];
            if (m == 0) {
                break;
            } else {
                int p = 0;
                for (int i = 0; i < m; i++) {
                    s = br.readLine();
                    for (int j = 0; j < n; j++) {
                        if (s.charAt(j) == '@') {
                            oil[i][j] = true;
                        }
                    }
                }
                for (int i = 0; i < m; i++) {
                    for (int j = 0; j < n; j++) {
                        if (oil[i][j]) {
                            BTc(i, j);
                            p++;
                        }
                    }
                }
                System.out.println(p);
            }
        }
    }