```
class Solution {
public:
int minArea(vector<vector<char>>& image, int x, int y) {
int left = INT_MAX, right = INT_MIN, up = INT_MAX, down = INT_MIN, N = image.size(), M = image[0].size();
for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) if (image[i][j] == '1') {
left = min(left, j); right = max(right, j); up = min(up, i); down = max(down, i);
}
return (down - up + 1) * (right - left + 1);
}
};
```