//#include <tourist>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//g++ yarudake.cpp -std=c++17 -I .
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, m;
pair<int, int> get_2d(ll k)
{
    pair<int, int> res = make_pair(k / m, k % m);
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    mf_graph<ll> g(n * m + 2); //n*mがソース,n*m+1がシンク
    rep(i, n)
    {
        rep(j, m)
        {
            if (s[i][j] == '#')
                continue;
            if ((i + j) % 2 == 0)
            {
                g.add_edge(n * m, i * m + j, 1);
                if (j != m - 1)
                {
                    if (s[i][j + 1] == '.')
                        g.add_edge(i * m + j, i * m + j + 1, 1);
                }
                if (j != 0)
                {
                    if (s[i][j - 1] == '.')
                        g.add_edge(i * m + j, i * m + j - 1, 1);
                }
                if (i != n - 1)
                {
                    if (s[i + 1][j] == '.')
                        g.add_edge(i * m + j, (i + 1) * m + j, 1);
                }
                if (i != 0)
                {
                    if (s[i - 1][j] == '.')
                        g.add_edge(i * m + j, (i - 1) * m + j, 1);
                }
            }
            else
            {
                g.add_edge(i * m + j, n * m + 1, 1);
            }
        }
    }
    g.flow(n * m, n * m + 1);
    int count = 0;
    vector<mf_graph<ll>::edge> v = g.edges();
    //cout<<v.size()<<"\n";
    rep(i, v.size())
    {
        if (v[i].from == n * m || v[i].to == n * m + 1 || v[i].flow == 0)
            continue;
        count++;
        ll diff = v[i].from - v[i].to;
        if (diff == 1 && m != 1)
        {
            pair<int, int> temp = get_2d(v[i].from);
            s[temp.first][temp.second] = '<';
            pair<int, int> temp1 = get_2d(v[i].to);
            s[temp1.first][temp1.second] = '>';
        }
        else if (diff == -1 && m != 1)
        {
            pair<int, int> temp = get_2d(v[i].from);
            s[temp.first][temp.second] = '>';
            pair<int, int> temp1 = get_2d(v[i].to);
            s[temp1.first][temp1.second] = '<';
        }
        else if (diff == m)
        {
            pair<int, int> temp = get_2d(v[i].from);
            s[temp.first][temp.second] = '^';
            pair<int, int> temp1 = get_2d(v[i].to);
            s[temp1.first][temp1.second] = 'v';
        }
        else
        {
            pair<int, int> temp = get_2d(v[i].from);
            s[temp.first][temp.second] = 'v';
            pair<int, int> temp1 = get_2d(v[i].to);
            s[temp1.first][temp1.second] = '^';
        }
    }
    cout << count << "\n";
    rep(i, n) cout << s[i] << "\n";
}

Measured memory_bytes: 6276