#include <stdio.h>
int main(void){
// 성의 행, 열 입력받기
int row, col;
scanf("%d %d", &row, &col);
// 열의 배열 초기화
int count_row = 0, count_col = col;
int col_arr[col];
for(int c = 0; c < col; c++){
col_arr[c] = 0;
}
// 추가해야하는 경비원 최솟값 구하기
for(int i = 0; i < row; i++){
int is_row = 0;
// 버퍼 비우기
getchar();
for(int j = 0; j < col; j++){
// 경비원이 있는지 없는지 입력받기
char guard = 0;
scanf("%c", &guard);
// 경비원이 있을 경우
if(guard == 'X'){
// 해당 행에 경비원이 있음을 표시
is_row = 1;
// 해당 열에 경비원이 없을경우
if(col_arr[j] == 0){
// 필요 경비원 카운트
count_col--;
// 해당 열에 경비원이 있음을 표시
col_arr[j] = 1;
}
}
}
// 해당 행에 경비원이 없으면
if(!is_row){
// 필요 경비원 카운트
count_row++;
}
}
// 필요한 경비원이 더 많은 쪽을 출력
if(count_col > count_row){
printf("%d", count_col);
}
else{
printf("%d", count_row);
}
return 0;
}