7536de4b3faeba67e471d60ff2622d7a4ce76ef8dc966ce631f9340693a15a54
// tresc: https://szkopul.edu.pl/problemset/problem/ZhrqkG9W7TYF2VPrIuR1Ufry/site/?key=statement
// OIG XV (3 etap)
#include <array>
#include <iostream>
constexpr int MAX_N = 1000 * 1000 + 7;
std::array<int, MAX_N> x;
std::array<int, MAX_N> y;
int main() {
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
int N, M;
std::cin >> N >> M;
int pionki = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
char a;
std::cin >> a;
if (a == '#') {
y[i]++;
x[j]++;
pionki++;
}
}
}
if (pionki == 0) {
std::cout << 0;
return 0;
}
int wynik = 1000 * 1000 * 1000 + 7;
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
int res = 2 * pionki - y[i] - x[j];
if (wynik > res) {
wynik = res;
}
}
}
std::cout << wynik;
return 0;
}