#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
struct UnionFind {
    parent: Vec<usize>,
    rank: Vec<usize>,
    size: Vec<usize>,
}

#[allow(dead_code)]
impl UnionFind {
    fn new(n: usize) -> UnionFind {
        let mut p = vec![0; n];
        for i in 0..n {
            p[i] = i;
        }
        return UnionFind {
            parent: p,
            rank: vec![0; n],
            size: vec![1; n],
        };
    }

    fn find(&mut self, x: usize) -> usize {
        if x == self.parent[x] {
            x
        } else {
            let p = self.parent[x];
            let pr = self.find(p);
            self.parent[x] = pr;
            pr
        }
    }

    fn same(&mut self, a: usize, b: usize) -> bool {
        self.find(a) == self.find(b)
    }

    fn unite(&mut self, a: usize, b: usize) {
        let a_root = self.find(a);
        let b_root = self.find(b);
        if self.rank[a_root] > self.rank[b_root] {
            self.parent[b_root] = a_root;
            self.size[a_root] += self.size[b_root];
        } else {
            self.parent[a_root] = b_root;
            self.size[b_root] += self.size[a_root];
            if self.rank[a_root] == self.rank[b_root] {
                self.rank[b_root] += 1;
            }
        }
    }

    fn get_size(&mut self, x: usize) -> usize {
        let root = self.find(x);
        self.size[root]
    }
}

use std::cmp::{max, min};

fn diff_abs(x: usize, y: usize) -> usize {
    max(x, y) - min(x, y)
}
fn main() {
    input! {
        h: usize,
        w: usize,
        ss: [chars; h]
    }

    let mut col = vec![Vec::new(); w];
    let mut row = vec![Vec::new(); h];

    for i in 0..w {
        for (j, s) in ss.iter().enumerate() {
            if s[i] == '#' {
                col[i].push(j);
            }
        }
    }

    for (i, s) in ss.iter().enumerate() {
        for j in 0..w {
            if s[j] == '#' {
                row[i].push(j);
            }
        }
    }

    let mut ans = 0;
    for i in 0..h {
        for j in 0..w {
            if ss[i][j] == '#' {
                continue;
            }

            let mut count = 0;

            if col[j].len() == 0 {
                count += h;
            } else {
                match col[j].binary_search(&i) {
                    Ok(x) => {
                        continue;
                    }
                    Err(0) => {
                        count += col[j][0];
                    }
                    Err(x) => {
                        if x == col[j].len() {
                            count += h - col[j][x - 1] - 1;
                        } else {
                            count += col[j][x] - col[j][x - 1] - 1;
                        }
                    }
                }
            }
            if row[i].len() == 0 {
                count += w;
            } else {
                match row[i].binary_search(&j) {
                    Ok(x) => {
                        continue;
                    }
                    Err(0) => {
                        count += row[i][0];
                    }
                    Err(x) => {
                        if x == row[i].len() {
                            count += w - row[i][x - 1] - 1;
                        } else {
                            count += row[i][x] - row[i][x - 1] - 1;
                        }
                    }
                }
            }
            ans = max(ans, count - 1);
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 102652