#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> board(n);

    for (int i = 0; i < n; i++) {
        cin >> board[i];
    }

    int cnt = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (board[i][j] == '-') {
                if (j == 0 || board[i][j - 1] == '|') {
                    cnt++;
                }
            } else if (board[i][j] == '|') {
                if (i == 0 || board[i - 1][j] == '-') {
                    cnt++;
                }
            }
        }
    }

    cout << cnt << endl;
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: