use max_flow::MfGraph;
use std::cmp::*;
use std::io::*;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o).unwrap();
    stdout().write_all(&o).unwrap();
}

pub fn run(i: impl BufRead, o: &mut impl Write) -> std::io::Result<()> {
    let mut i = CpReader::new(i);
    let (n, m) = i.read::<(usize, usize)>();
    let mut s = Vec::new();
    for _ in 0..n {
        s.push(i.read_line().to_vec());
    }
    let mut g = MfGraph::new(n * m + 2);
    let start = n * m;
    let goal = n * m + 1;
    for y in 0..n {
        for x in 0..m {
            if s[y][x] == b'.' {
                let v = y * m + x;
                if (y + x) % 2 == 0 {
                    g.add_edge(start, v, 1);
                } else {
                    g.add_edge(v, goal, 1);
                }
            }
        }
    }
    for y in 0..n {
        for x in 0..m {
            let v = y * m + x;
            if (y + x) % 2 == 0 && s[y][x] == b'.' {
                if y > 0 && s[y - 1][x] == b'.' {
                    g.add_edge(v, v - m, 1);
                }
                if y + 1 < n && s[y + 1][x] == b'.' {
                    g.add_edge(v, v + m, 1);
                }
                if x > 0 && s[y][x - 1] == b'.' {
                    g.add_edge(v, v - 1, 1);
                }
                if x + 1 < m && s[y][x + 1] == b'.' {
                    g.add_edge(v, v + 1, 1);
                }
            }
        }
    }
    let f = g.flow(start, goal);
    for edge in g.edges() {
        if edge.from == start || edge.to == goal || edge.flow == 0 {
            continue;
        }
        let from_x = edge.from % m;
        let from_y = edge.from / m;
        let to_x = edge.to % m;
        let to_y = edge.to / m;

        let min_x = min(from_x, to_x);
        let max_x = max(from_x, to_x);
        let min_y = min(from_y, to_y);
        let max_y = max(from_y, to_y);

        if min_y == max_y {
            s[min_y][min_x] = b'>';
            s[max_y][max_x] = b'<';
        }
        if min_x == max_x {
            s[min_y][min_x] = b'v';
            s[max_y][max_x] = b'^';
        }
    }
    writeln!(o, "{}", f)?;
    for s in &s {
        writeln!(o, "{}", std::str::from_utf8(s).unwrap())?;
    }
    Ok(())
}

pub mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        b: Vec<u8>,
    }
    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                b: Vec::new(),
            }
        }
        pub fn read_word(&mut self) -> &[u8] {
            self.b.clear();
            loop {
                let b = self.r.fill_buf().unwrap();
                assert!(!b.is_empty());
                if let Some(p) = b.iter().position(|&x| x == b' ' || x == b'\n') {
                    self.b.extend_from_slice(&b[..p]);
                    self.r.consume(p + 1);
                    return &self.b;
                }
                self.b.extend_from_slice(b);
                let b_len = b.len();
                self.r.consume(b_len);
            }
        }
        pub fn read_word_str(&mut self) -> &str {
            unsafe { std::str::from_utf8_unchecked(self.read_word()) }
        }

        pub fn read_line(&mut self) -> &[u8] {
            self.b.clear();
            self.r.read_until(b'\n', &mut self.b).unwrap();
            if self.b.last() == Some(&b'\n') {
                &self.b[..self.b.len() - 1]
            } else {
                &self.b
            }
        }
        pub fn read_line_str(&mut self) -> &str {
            unsafe { std::str::from_utf8_unchecked(self.read_line()) }
        }

        pub fn read<T: CpIn>(&mut self) -> T {
            T::read_from(self)
        }

        pub fn read_vec<T: CpIn>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.read()).collect()
        }
        pub fn read_iter<'a, T: CpIn>(&'a mut self, n: usize) -> CpIter<'a, R, T> {
            CpIter {
                r: self,
                n: n,
                _pd: Default::default(),
            }
        }
    }
    pub struct CpIter<'a, R: BufRead + 'a, T> {
        r: &'a mut CpReader<R>,
        n: usize,
        _pd: std::marker::PhantomData<fn() -> T>,
    }
    impl<'a, R: BufRead, T: CpIn> Iterator for CpIter<'a, R, T> {
        type Item = T;
        fn next(&mut self) -> Option<T> {
            if self.n == 0 {
                None
            } else {
                self.n -= 1;
                Some(self.r.read())
            }
        }
        fn size_hint(&self) -> (usize, Option<usize>) {
            (self.n, Some(self.n))
        }
    }
    impl<'a, R: BufRead, T: CpIn> ExactSizeIterator for CpIter<'a, R, T> {}

    pub trait CpIn {
        fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self;
    }

    impl CpIn for u64 {
        fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self {
            read_u64_fast(&mut r.r)
        }
    }
    impl CpIn for i64 {
        fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self {
            read_i64_fast(&mut r.r)
        }
    }
    impl CpIn for char {
        fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self {
            let b = r.r.fill_buf().unwrap()[0] as char;
            r.r.consume(1);
            let s = r.r.fill_buf().unwrap()[0];
            assert!(s == b' ' || s == b'\n');
            r.r.consume(1);
            b
        }
    }

    macro_rules! cpin_tuple {
        ($($t:ident),*) => {
            impl<$($t: CpIn),*> CpIn for ($($t),*) {
                fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self {
                    ($($t::read_from(r)),*)
                }
            }
        };
    }

    macro_rules! cpin_cast {
        ($t_self:ty, $t_read:ty) => {
            impl CpIn for $t_self {
                fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self {
                    <$t_read>::read_from(r) as $t_self
                }
            }
        };
    }
    macro_rules! cpin_parse {
        ($t:ty) => {
            impl CpIn for $t {
                fn read_from<R: BufRead>(r: &mut CpReader<R>) -> Self {
                    r.read_word_str().parse().unwrap()
                }
            }
        };
    }
    cpin_cast!(usize, u64);
    cpin_cast!(u32, u64);
    cpin_cast!(u16, u64);
    cpin_cast!(i32, i64);
    cpin_cast!(i16, i64);
    cpin_cast!(i8, i64);

    cpin_parse!(f64);

    cpin_tuple!(T1, T2);
    cpin_tuple!(T1, T2, T3);
    cpin_tuple!(T1, T2, T3, T4);
    cpin_tuple!(T1, T2, T3, T4, T5);

    fn read_u64_fast<R: BufRead>(r: &mut R) -> u64 {
        let mut value = 0;
        loop {
            let buf = r.fill_buf().unwrap();
            assert!(!buf.is_empty());
            let mut idx = 0;
            while let Some(&c) = buf.get(idx) {
                if b'0' <= c && c <= b'9' {
                    value = value * 10 + (c - b'0') as u64;
                    idx += 1;
                } else {
                    r.consume(idx + 1);
                    return value;
                }
            }
            r.consume(idx);
        }
    }
    fn read_i64_fast<R: BufRead>(r: &mut R) -> i64 {
        let sign = match r.fill_buf().unwrap()[0] {
            b'+' => {
                r.consume(1);
                1
            }
            b'-' => {
                r.consume(1);
                -1
            }
            _ => 1,
        };
        read_u64_fast(r) as i64 * sign
    }
}
mod max_flow {
    #![allow(dead_code)]

    use std::{
        cmp::min,
        collections::VecDeque,
        fmt::Debug,
        ops::AddAssign,
        ops::SubAssign,
        ops::{Add, Sub},
    };

    use num::{zero, Bounded, Zero};

    pub struct MfGraph<Cap> {
        n: usize,
        pos: Vec<(usize, usize)>,
        g: Vec<Vec<EdgeData<Cap>>>,
    }
    pub struct Edge<Cap> {
        pub from: usize,
        pub to: usize,
        pub cap: Cap,
        pub flow: Cap,
    }

    #[derive(Clone, Copy, Debug, Default)]
    struct EdgeData<Cap> {
        to: usize,
        rev: usize,
        cap: Cap,
    }

    impl<
            Cap: Copy
                + Zero
                + Add<Cap>
                + AddAssign
                + Sub<Cap, Output = Cap>
                + SubAssign
                + Ord
                + Bounded
                + Debug,
        > MfGraph<Cap>
    {
        pub fn new(n: usize) -> Self {
            Self {
                n,
                pos: Vec::new(),
                g: vec![Vec::new(); n],
            }
        }

        pub fn add_edge(&mut self, from: usize, to: usize, cap: Cap) -> usize {
            debug_assert!(from < self.n);
            debug_assert!(to < self.n);
            let m = self.pos.len();
            self.pos.push((from, self.g[from].len()));

            let rev = self.g[to].len();
            self.g[from].push(EdgeData { to, rev, cap });

            let rev = self.g[from].len() - 1;
            self.g[to].push(EdgeData {
                to: from,
                rev,
                cap: zero(),
            });
            m
        }
        pub fn get_edge(&self, i: usize) -> Edge<Cap> {
            let m = self.pos.len();
            debug_assert!(i < m);
            let e = &self.g[self.pos[i].0][self.pos[i].1];
            let re = &self.g[e.to][e.rev];
            Edge {
                from: self.pos[i].0,
                to: e.to,
                cap: e.cap + re.cap,
                flow: re.cap,
            }
        }
        pub fn edges(&self) -> Vec<Edge<Cap>> {
            let m = self.pos.len();
            let mut result = Vec::new();
            for i in 0..m {
                result.push(self.get_edge(i));
            }
            result
        }
        pub fn change_edge(&mut self, i: usize, new_cap: Cap, new_flow: Cap) {
            let m = self.pos.len();
            debug_assert!(i < m);
            debug_assert!(new_flow <= new_cap);
            let e = &mut self.g[self.pos[i].0][self.pos[i].1];
            e.cap = new_cap - new_flow;

            let (e_to, e_rev) = (e.to, e.rev);
            let re = &mut self.g[e_to][e_rev];
            re.cap = new_flow;
        }
        pub fn flow(&mut self, s: usize, t: usize) -> Cap {
            self.flow_with_limit(s, t, Cap::max_value())
        }
        pub fn flow_with_limit(&mut self, s: usize, t: usize, flow_limit: Cap) -> Cap {
            debug_assert!(s < self.n);
            debug_assert!(t < self.n);

            let mut level = vec![0; self.n];
            let mut iter = vec![0; self.n];
            let mut que = VecDeque::new();

            fn dfs<
                Cap: Copy
                    + Zero
                    + Add<Cap>
                    + AddAssign
                    + Sub<Cap, Output = Cap>
                    + SubAssign
                    + Ord
                    + Bounded
                    + Debug,
            >(
                v: usize,
                up: Cap,
                s: usize,
                level: &[i32],
                iter: &[usize],
                this: &mut MfGraph<Cap>,
            ) -> Cap {
                if v == s {
                    return up;
                }
                let mut res = zero();
                let level_v = level[v];
                for i in iter[v]..this.g[v].len() {
                    let e = &this.g[v][i];
                    let e_to = e.to;
                    let e_rev = e.rev;
                    if level_v <= level[e.to] || this.g[e.to][e.rev].cap == zero() {
                        continue;
                    }
                    let d = dfs(
                        e_to,
                        min(up - res, this.g[e_to][e_rev].cap),
                        s,
                        level,
                        iter,
                        this,
                    );
                    if d <= zero() {
                        continue;
                    }
                    this.g[v][i].cap += d;
                    this.g[e_to][e_rev].cap -= d;
                    res += d;
                    if res == up {
                        break;
                    }
                }
                res
            };
            let mut flow = zero();
            while flow < flow_limit {
                let mut bfs = || {
                    for x in &mut level {
                        *x = -1;
                    }
                    level[s] = 0;
                    que.clear();
                    que.push_back(s);
                    while let Some(v) = que.pop_front() {
                        for e in &self.g[v] {
                            if e.cap == zero() || level[e.to] >= 0 {
                                continue;
                            }
                            level[e.to] = level[v] + 1;
                            if e.to == t {
                                return;
                            }
                            que.push_back(e.to);
                        }
                    }
                };
                bfs();
                if level[t] == -1 {
                    break;
                }
                for x in &mut iter {
                    *x = 0;
                }
                while flow < flow_limit {
                    let f = dfs(t, flow_limit - flow, s, &level, &iter, self);
                    if f == zero() {
                        break;
                    }
                    flow += f;
                }
            }
            flow
        }
        pub fn min_cut(&self, s: usize) -> Vec<bool> {
            let mut visited = vec![false; self.n];
            let mut que = VecDeque::new();
            que.push_back(s);
            while let Some(p) = que.pop_front() {
                visited[p] = true;
                for &e in &self.g[p] {
                    if e.cap != zero() && !visited[e.to] {
                        visited[e.to] = true;
                        que.push_back(e.to);
                    }
                }
            }
            visited
        }
    }
}


Measured memory_bytes: 5780