#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) \
    do               \
    {                \
    } while (0)
#endif
#include <cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(), i##_end = (c).end(); i != i##_end; ++i)

template <class T>
inline void amin(T &x, const T &y)
{
    if (y < x)
        x = y;
}
template <class T>
inline void amax(T &x, const T &y)
{
    if (x < y)
        x = y;
}
#define rprintf(fmt, begin, end)                       \
    do                                                 \
    {                                                  \
        const auto end_rp = (end);                     \
        auto it_rp = (begin);                          \
        for (bool sp_rp = 0; it_rp != end_rp; ++it_rp) \
        {                                              \
            if (sp_rp)                                 \
                putchar(' ');                          \
            else                                       \
                sp_rp = true;                          \
            printf(fmt, *it_rp);                       \
        }                                              \
        putchar('\n');                                 \
    } while (0)

int H, W;
char S[111][111];

void MAIN()
{
    scanf("%d%d", &H, &W);
    REP(i, H)
    scanf("%s", S[i]);

    int ans = 0;
    REP(i, H - 1)
    REP(j, W - 1)
    {
        int cnt = 0;
        if (S[i][j] == S[i][j + 1])
            cnt++;
        if (S[i][j] == S[i + 1][j])
            cnt++;
        if (S[i][j] == S[i + 1][j + 1])
            cnt++;

        if (cnt == 0 || cnt == 2)
            ans++;
    }

    printf("%d\n", ans);
}

int main()
{
    int TC = 1;
    //    scanf("%d", &TC);
    REP(tc, TC)
    MAIN();
    return 0;
}
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <sstream>
#include <iomanip>
using namespace std;

using VI = vector <int>;
using VVI = vector <VI>;
using VVVI = vector <VVI>;
using VLL = vector <long long>;
using VVLL = vector <VLL>;
using UMI = unordered_map<int, int>;
using UMLL = unordered_map<long long, long long>;


int main() {
    long long ans = 0;
    int L;
    int R;
    cin >> L >> R;

    VI primes;
    int UPPER = R+10;
    VI np(UPPER);
    VI factCnt(UPPER, 0);
    VI onlyOne(UPPER, 1);
    VI ooo(UPPER, 1);

    // 2*2*3
    // 2, 3, 2*2, 2*3, 2*2*3
    for (long long v = 2; v < np.size(); ++v) {
        if (np[v] == 0) {
            primes.push_back(v);


            ++factCnt[v];
            for (long long j = v*2; j < np.size(); j += v) {
                ++factCnt[j];
                np[j] = 1;
                if (j%(v*v) == 0) {
                    // onlyOne[j] = 0;
                    ooo[j] = 0;
                }
            }

            for (long long j = v*v; j < np.size(); j += v*v) {
                // if (j == 14369) {
                //     cout << "DEBUG " << v << endl;
                // }
                onlyOne[j] = 0;
            }
        }

        // for (int j = 0; j < primes.size() && v*primes[j] < np.size(); ++j) {
        //     np[v*primes[j]] = 1;
        //     factCnt[v*primes[j]] = factCnt[v];

        //     if (v%primes[j] == 0) {
        //         onlyOne[v*primes[j]] = 0;
        //         break;
        //     } else {
        //         ++factCnt[v*primes[j]];
        //     }
        // }
    }

    // for (long long v = 2; v < np.size(); ++v) {
    //     if (ooo[v] != onlyOne[v]) {
    //         cout << "WHY " << v << " " << ooo[v] << " " << onlyOne[v] << endl;
    //     }
    // }

    for (long long g = 2; g <= R; ++g) {
        long long from = max(1LL, (L+g-1)/g);
        long long to = R/g;

        long long cho = to-from+1;
        // long long cho = to - (L-1)/g;
        long long sign = factCnt[g]%2 == 0 ? -1 : 1;

        // cout << "CHO " << cho << endl;
        if (cho >= 1 && onlyOne[g]) {
            ans += sign * cho * (cho-1) / 2;
        }

        if (from <= 1 && to >= from) {
            ans -= (to-1);
        }

        // cout << sign << " " << onlyOne[g] << " " << g << " DEBUG " << from << " " << to << " " << ans << endl;
    }

    cout << ans*2 << endl;

    return 0;
}