0pts
#include <bits/stdc++.h>
#include <iostream>
#include <time.h>
#include <stdlib.h>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <stack>
#include <queue>
#include <vector>
#include <numeric>
using namespace std;
typedef long long ll;
int n, m;
int a[1010][1010];
int ans = 0;
char s;
signed main() {
scanf ("%d%d\n", &n, &m);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
scanf ("%c", &s);
a[i][j] = s - '0';
}
scanf ("%*c");
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (a[i][j] > 0) {
ans++;
}
}
}
int tot1 = 0, tot2 = 0;
for (int j = 1; j <= m; j++) {
tot1 += a[1][j];
for (int i = 2; i <= n; i++) {
if (a[i][j] > a[i - 1][j]) {
tot1 += (a[i][j] - a[i - 1][j]);
}
}
}
for (int i = 1; i <= n; i++) {
tot2 += a[i][1];
for (int j = 2; j <= m; j++) {
if (a[i][j] > a[i][j - 1]) {
tot2 += (a[i][j] - a[i][j - 1]);
}
}
}
cout << (ans + tot1 + tot2) * 2;
return 0;
}