#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-10;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

using Real = double;
using Point = complex<Real>;

inline bool eq(Real a, Real b) { return fabs(b - a) < EPS; }

Point operator*(const Point &p, const Real &d)
{
  return Point(real(p) * d, imag(p) * d);
}

istream &operator>>(istream &is, Point &p)
{
  Real a, b;
  is >> a >> b;
  p = Point(a, b);
  return is;
}

ostream &operator<<(ostream &os, Point &p)
{
  return os << fixed << setprecision(20) << p.real() << " " << p.imag();
}

// 点 p を反時計回りに theta 回転
inline Point rotate(Real theta, const Point &p)
{
  return Point(cos(theta) * p.real() - sin(theta) * p.imag(), sin(theta) * p.real() + cos(theta) * p.imag());
}

Real radian_to_degree(Real r)
{
  return (r * 180.0 / PI);
}

Real degree_to_radian(Real d)
{
  return (d * PI / 180.0);
}

// a-b-c の角度のうち小さい方を返す
Real get_angle(const Point &a, const Point &b, const Point &c)
{
  const Point v(a - b), w(c - b);
  Real alpha = atan2(v.imag(), v.real()), beta = atan2(w.imag(), w.real());
  if (alpha > beta)
    swap(alpha, beta);
  Real theta = (beta - alpha);
  return min(theta, 2 * acos(-1) - theta);
}

namespace std
{
  bool operator<(const Point &a, const Point &b)
  {
    return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag();
  }
} // namespace std

void solve()
{
  int h, w;
  cin >> h >> w;
  string s[610];
  s[0] = s[h + 1] = string(w + 1, '.');
  rep(i, h)
  {
    cin >> s[i + 1];
    s[i + 1].push_back('.');
  }

  vector<pair<double, int>> v;
  rep(i, h + 1) rep(j, w)
  {
    Point p(j + 1, h - i);
    if (s[i][j] == '#' and s[i + 1][j] == '.' and s[i][j + 1] == '.' and s[i + 1][j + 1] == '.')
      v.push_back(MP(arg(p) + EPS, 1));
    else if (s[i][j] == '.' and s[i + 1][j] == '#' and s[i][j + 1] == '#' and s[i + 1][j + 1] == '#')
      v.push_back(MP(arg(p) + EPS, 1));
    else if (s[i][j] == '#' and s[i + 1][j] == '#' and s[i][j + 1] == '#' and s[i + 1][j + 1] == '.')
      v.push_back(MP(arg(p) - EPS, -1));
    else if (s[i][j] == '.' and s[i + 1][j] == '.' and s[i][j + 1] == '.' and s[i + 1][j + 1] == '#')
      v.push_back(MP(arg(p) - EPS, -1));
  }
  sort(all(v));

  int Max = 1, now = 1;
  double theta;
  int t;
  for (auto p : v)
  {
    tie(theta, t) = p;
    now += t;
    chmax(Max, now);
  }
  cout << Max << "\n";
}

int main()
{
  init_main();

  solve();

  return 0;
}



Measured memory_bytes: 6052