fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn manhattan_dist(x1: i32, y1: i32, x2: i32, y2: i32) -> usize {
    ((x1 - x2).abs() + (y1 - y2).abs()) as usize
}

fn main() {
    let v: Vec<usize> = read_vec();
    let (h, w) = (v[0], v[1]);
    let mut grid: Vec<Vec<bool>> = Vec::new();
    for _ in 0..h {
        let s: String = read();
        let mut line: Vec<bool> = Vec::new();
        for ch in s.chars() {
            if ch == '#' {
                line.push(true);
            } else {
                line.push(false);
            }
        }
        grid.push(line);
    }

    let mut rt_to_lb_group = Vec::new();
    for i in 0..h + w - 1 {
        let mut x = 0;
        let mut y = i as i32;
        let mut line = Vec::new();
        while y >= 0 && x < w as i32 {
            if x >= 0 && x < w as i32 && y >= 0 && y < h as i32 && grid[y as usize][x as usize] {
                // if x >= 0 && x < w as i32 && y >= 0 && y < h as i32 {
                line.push((x, y));
            }
            x += 1;
            y -= 1;
        }
        rt_to_lb_group.push(line);
    }

    // println!("{:?}", rt_to_lb_group);

    let mut rb_to_lt_group = Vec::new();
    for i in 0..h + w - 1 {
        let mut x = 0;
        let mut y = h as i32 - i as i32 - 1;
        let mut line = Vec::new();
        while x >= 0 && y < h as i32 {
            if x >= 0 && x < w as i32 && y >= 0 && y < h as i32 && grid[y as usize][x as usize] {
                // if x >= 0 && x < w as i32 && y >= 0 && y < h as i32 {
                line.push((x, y));
            }
            x += 1;
            y += 1;
        }
        rb_to_lt_group.push(line);
    }

    // println!("{:?}", rb_to_lt_group);

    let mut ans_set = std::collections::HashSet::new();

    for (line_index, line) in rt_to_lb_group.iter().by_ref().enumerate() {
        if line.len() < 2 {
            continue;
        }
        for i in 0..line.len() - 1 {
            for j in i + 1..line.len() {
                let dist = manhattan_dist(line[i].0, line[i].1, line[j].0, line[j].1);
                if line_index >= dist {
                    for (x, y) in &rt_to_lb_group[line_index - dist] {
                        let dist1 = manhattan_dist(line[i].0, line[i].1, *x, *y);
                        let dist2 = manhattan_dist(line[j].0, line[j].1, *x, *y);
                        if dist1 == dist && dist == dist2 {
                            let mut new_ans =
                                vec![(line[i].0, line[i].1), (line[j].0, line[j].1), (*x, *y)];
                            new_ans.sort();
                            ans_set.insert(new_ans);
                        }
                    }
                }
                if line_index + dist < rt_to_lb_group.len() {
                    for (x, y) in &rt_to_lb_group[line_index + dist] {
                        if manhattan_dist(line[i].0, line[i].1, *x, *y) == dist
                            && manhattan_dist(line[j].0, line[j].1, *x, *y) == dist
                        {
                            let mut new_ans =
                                vec![(line[i].0, line[i].1), (line[j].0, line[j].1), (*x, *y)];
                            new_ans.sort();
                            ans_set.insert(new_ans);
                        }
                    }
                }
            }
        }
    }

    for (line_index, line) in rb_to_lt_group.iter().by_ref().enumerate() {
        if line.len() < 2 {
            continue;
        }
        for i in 0..line.len() - 1 {
            for j in i + 1..line.len() {
                let dist = manhattan_dist(line[i].0, line[i].1, line[j].0, line[j].1);
                if line_index >= dist {
                    for (x, y) in &rb_to_lt_group[line_index - dist] {
                        let dist1 = manhattan_dist(line[i].0, line[i].1, *x, *y);
                        let dist2 = manhattan_dist(line[j].0, line[j].1, *x, *y);
                        if dist1 == dist && dist == dist2 {
                            let mut new_ans =
                                vec![(line[i].0, line[i].1), (line[j].0, line[j].1), (*x, *y)];
                            new_ans.sort();
                            ans_set.insert(new_ans);
                        }
                    }
                }
                if line_index + dist < rb_to_lt_group.len() {
                    for (x, y) in &rb_to_lt_group[line_index + dist] {
                        if manhattan_dist(line[i].0, line[i].1, *x, *y) == dist
                            && manhattan_dist(line[j].0, line[j].1, *x, *y) == dist
                        {
                            let mut new_ans =
                                vec![(line[i].0, line[i].1), (line[j].0, line[j].1), (*x, *y)];
                            new_ans.sort();
                            ans_set.insert(new_ans);
                        }
                    }
                }
            }
        }
    }
    println!("{:?}", ans_set.len());
}
