package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"runtime"
	"strconv"
)

var DEBUG = false

func main() {
	defer Flush()

	N := readi()
	M := readi()

	grid := make([][]byte, N)
	for i := range grid {
		grid[i] = readb()
	}

	g := NewMaxFlow(N*M + 2)

	s := N * M
	t := N*M + 1

	for i := 0; i < N; i++ {
		for j := 0; j < M; j++ {
			if grid[i][j] == '#' {
				continue
			}
			v := i*M + j
			if (i+j)%2 == 0 {
				g.AddEdge(s, v, 1)
			} else {
				g.AddEdge(v, t, 1)
			}
		}
	}

	for i := 0; i < N; i++ {
		for j := 0; j < M; j++ {
			if (i+j)%2 == 1 || grid[i][j] == '#' {
				continue
			}
			v0 := i*M + j
			if 0 < i && grid[i-1][j] == '.' {
				v1 := (i-1)*M + j
				g.AddEdge(v0, v1, 1)
			}
			if 0 < j && grid[i][j-1] == '.' {
				v1 := i*M + (j - 1)
				g.AddEdge(v0, v1, 1)
			}
			if i+1 < N && grid[i+1][j] == '.' {
				v1 := (i+1)*M + j
				g.AddEdge(v0, v1, 1)
			}
			if j+1 < M && grid[i][j+1] == '.' {
				v1 := i*M + (j + 1)
				g.AddEdge(v0, v1, 1)
			}

		}
	}

	println(g.Flow(s, t))

	edges := g.Edges()
	for _, e := range edges {
		if e.from == s || e.to == t || e.flow == 0 {
			continue
		}
		i0 := e.from / M
		j0 := e.from % M
		i1 := e.to / M
		j1 := e.to % M

		if i0 == i1+1 {
			grid[i1][j1] = 'v'
			grid[i0][j0] = '^'
		} else if j0 == j1+1 {
			grid[i1][j1] = '>'
			grid[i0][j0] = '<'
		} else if i0 == i1-1 {
			grid[i0][j0] = 'v'
			grid[i1][j1] = '^'
		} else {
			grid[i0][j0] = '>'
			grid[i1][j1] = '<'
		}

	}

	for i := 0; i < N; i++ {
		println(string(grid[i]))
	}

}

type MaxFlowEdge struct {
	from, to   int
	capa, flow int
}

type _maxFlowEdge struct {
	to, rev int
	capa    int
}

type MaxFlow struct {
	n   int
	pos [][2]int
	g   [][]_maxFlowEdge
}

func NewMaxFlow(n int) *MaxFlow {
	return &MaxFlow{
		n: n,
		g: make([][]_maxFlowEdge, n),
	}
}

func (mf *MaxFlow) assert(exp bool) {
	if exp {
		return
	}

	pc, file, line, ok := runtime.Caller(1)
	if !ok {
		panic("ASSERT!: unknown position")
	}
	msg := fmt.Sprintf("ASSERT!: @%p %s[%d]", pc, file, line)
	panic(msg)
}

func (mf *MaxFlow) min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func (mf *MaxFlow) AddEdge(from, to, capa int) int {
	mf.assert(0 <= from && from < mf.n)
	mf.assert(0 <= to && to < mf.n)
	mf.assert(0 <= capa)
	m := len(mf.pos)
	mf.pos = append(mf.pos, [2]int{from, len(mf.g[from])})
	mf.g[from] = append(mf.g[from], _maxFlowEdge{to, len(mf.g[to]), capa})
	mf.g[to] = append(mf.g[to], _maxFlowEdge{from, len(mf.g[from]) - 1, 0})
	return m
}

func (mf *MaxFlow) GetEdge(i int) MaxFlowEdge {
	m := len(mf.pos)
	mf.assert(0 <= i && i < m)
	e := mf.g[mf.pos[i][0]][mf.pos[i][1]]
	re := mf.g[e.to][e.rev]
	return MaxFlowEdge{mf.pos[i][0], e.to, e.capa + re.capa, re.capa}
}

func (mf *MaxFlow) Edges() []MaxFlowEdge {
	m := len(mf.pos)
	res := make([]MaxFlowEdge, m)
	for i := range res {
		res[i] = mf.GetEdge(i)
	}
	return res
}

func (mf *MaxFlow) ChangeEdge(i, newCapa, newFlow int) {
	m := len(mf.pos)
	mf.assert(0 <= i && i < m)
	mf.assert(0 <= newFlow && newFlow <= newCapa)
	e := &mf.g[mf.pos[i][0]][mf.pos[i][1]]
	re := &mf.g[e.to][e.rev]
	e.capa = newCapa - newFlow
	re.capa = newFlow
}

func (mf *MaxFlow) Flow(s, t int) int {
	return mf.FlowWithLimit(s, t, int(1e+18)+1)
}

func (mf *MaxFlow) FlowWithLimit(s, t, flowLimit int) int {
	mf.assert(0 <= s && s < mf.n)
	mf.assert(0 <= t && t < mf.n)

	level := make([]int, mf.n)
	iter := make([]int, mf.n)

	que := make([]int, 0)
	que_empty := func() bool {
		return len(que) == 0
	}
	que_clear := func() {
		que = que[:0]
	}
	que_push := func(v int) {
		que = append(que, v)
	}
	que_pop := func() int {
		v := que[0]
		que = que[1:]
		return v
	}

	bfs := func() {
		for i := range level {
			level[i] = -1
		}
		level[s] = 0
		que_clear()
		que_push(s)
		for !que_empty() {
			v := que_pop()
			for _, e := range mf.g[v] {
				if e.capa == 0 || level[e.to] >= 0 {
					continue
				}
				level[e.to] = level[v] + 1
				if e.to == t {
					return
				}
				que_push(e.to)
			}
		}
	}

	var dfs func(v, up int) int
	dfs = func(v, up int) int {
		if v == s {
			return up
		}
		var res int
		level_v := level[v]
		for ; iter[v] < len(mf.g[v]); iter[v]++ {
			i := iter[v]
			e := &mf.g[v][i]
			if level_v <= level[e.to] || mf.g[e.to][e.rev].capa == 0 {
				continue
			}
			d := dfs(e.to, mf.min(up-res, mf.g[e.to][e.rev].capa))
			if d <= 0 {
				continue
			}
			mf.g[v][i].capa += d
			mf.g[e.to][e.rev].capa -= d
			res += d
			if res == up {
				break
			}

		}
		return res
	}

	var flow int
	for flow < flowLimit {
		bfs()
		if level[t] == -1 {
			break
		}
		for i := range iter {
			iter[i] = 0
		}
		for flow < flowLimit {
			f := dfs(t, flowLimit-flow)
			if f == 0 {
				break
			}
			flow += f
		}
	}
	return flow
}

func (mf *MaxFlow) MinCut(s int) []bool {
	visited := make([]bool, mf.n)

	que := make([]int, 0)
	que_empty := func() bool {
		return len(que) == 0
	}
	que_push := func(v int) {
		que = append(que, v)
	}
	que_pop := func() int {
		v := que[0]
		que = que[1:]
		return v
	}

	que_push(s)
	for !que_empty() {
		p := que_pop()
		visited[p] = true
		for _, e := range mf.g[p] {
			if 0 < e.capa && !visited[e.to] {
				visited[e.to] = true
				que_push(e.to)
			}
		}
	}
	return visited
}

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

func readberr() ([]byte, error) {
	b, err := nextToken()
	return b[:len(b):len(b)], err
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

func readserr() (string, error) {
	b, err := readberr()
	return string(b), err
}

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

func readblnerr() ([]byte, error) {
	b, err := nextLine()
	return b[:len(b):len(b)], err
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

func readslnerr() (string, error) {
	b, err := readblnerr()
	return string(b), err
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readllerr() (int64, error) {
	s, err := readserr()
	if err != nil {
		return 0, fmt.Errorf("reading string: %w", err)
	}

	i, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		return 0, fmt.Errorf("parsing int: %w", err)
	}

	return i, nil
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

func readierr() (int, error) {
	i, err := readllerr()
	return int(i), err
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func readferr() (float64, error) {
	s, err := readserr()
	if err != nil {
		return 0, fmt.Errorf("reading string: %w", err)
	}

	f, err := strconv.ParseFloat(s, 64)
	if err != nil {
		return 0, fmt.Errorf("parsing float: %w", err)
	}

	return f, nil
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func dbgf(f string, args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintf(os.Stderr, f, args...)
}

func dbg(args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minf(a, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxll(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxf(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func absf(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}


Measured memory_bytes: 8872