def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N, M = getNM()
n = N # 保存用
m = M # 保存用
S = [list(input()) for i in range(N)]

# 変換1
def change(y, x):
    return y * M + (x + 1)

def change_rev(z):
    sz = z - 1
    y_opt = sz // m
    return y_opt, sz - m * y_opt

# 変換2
def change2(y, x):
    return N * M + y * M + (x + 1)

def change2_rev(z):
    sz = z - n * m - 1
    y_opt = sz // m
    return y_opt, sz - m * y_opt

query = []
for i in range(N):
    for j in range(M):
        if S[i][j] == '.':
            query.append([0, change(i, j), 1])
            query.append([change2(i, j), 2 * N * M + 1, 1])

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
for i in range(N):
    for j in range(M):
        if (i + j) % 2 == 0:
            continue
        for k in range(4):
            ny = i + dy[k]
            nx = j + dx[k]
            if 0 <= ny < N and 0 <= nx < M and S[i][j] == '.' and S[ny][nx] == '.':
                query.append([change(i, j), change2(ny, nx), 1])

query.sort()

N = 2 * N * M + 2
ans = 0
lines = defaultdict(set)
cost = defaultdict(lambda: defaultdict(int))
for i in range(len(query)):
    a, b, c = query[i]
    if c != 0:
        lines[a].add(b)
        cost[a][b] += c

def Ford_Fulkerson(sta, end):
    global ans
    queue = deque()
    queue.append([sta, float('inf')])

    ignore = [1] * N
    ignore[sta] = 0

    route = [0] * N
    route[sta] = -1

    while queue:
        s, flow = queue.pop()
        for t in lines[s]:  #s->t
            if ignore[t]: #未到達
                # flowは入ってくる量、出る量のうち小さい方
                flow = min(cost[s][t], flow)
                route[t] = s
                queue.append([t, flow])
                ignore[t] = 0
                if t == end: #ゴール到達
                    ans += flow
                    break
        else:
            continue #breakされなければWhile節の先頭に戻る
        # Falseはされない
        break
    else:
        return False

    t = end
    s = route[t]
    # goalまで流れた量はflow
    # 逆向きの辺を貼る
    while s != -1:
        #s->tのコスト減少，ゼロになるなら辺を削除
        cost[s][t] -= flow
        if cost[s][t] == 0:
            lines[s].remove(t)
            #t->s(逆順)のコスト増加，元がゼロなら辺を作成
        if cost[t][s] == 0:
            lines[t].add(s)

        cost[t][s] += flow

        # 一つ上の辺をたどる
        t = s
        s = route[t]

    return True

while True:
    # ちょびちょび流して行ってゴールまで流れなくなったら終了
    if Ford_Fulkerson(0, N - 1):
        continue
    else:
        break
cost_aft = deepcopy(cost)
print(ans)
alta = deepcopy(S)

for key, value in cost_aft.items():
    if key == 0 or n * m < key:
        continue
    for k, v in value.items():
        if v == 0:
            sy, sx = change_rev(key)
            ey, ex = change2_rev(k)
            s1y = min(sy, ey)
            e1y = max(sy, ey)
            s1x = min(sx, ex)
            e1x = max(sx, ex)
            if sy == ey:
                alta[s1y][s1x] = '>'
                alta[e1y][e1x] = '<'
            else:
                alta[s1y][s1x] = 'v'
                alta[e1y][e1x] = '^'
for i in alta:
    print(''.join(i))

Measured memory_bytes: 190668