import java.util.*;
import java.io.*;
public class joi2019ho_t1 {
final static int MOD = 1000000007;
final static int intMax = 1000000000;
final static int intMin = -1000000000;
final static int[] dx = { 0, 0, -1, 1 };
final static int[] dy = { -1, 1, 0, 0 };
static int add(int a, int b) {
return (a + b) % MOD;
}
static int sub(int a, int b) {
return (a - b + MOD) % MOD;
}
static int mult(int a, int b) {
return (int)((((long)(a)) * b) % MOD);
}
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// BufferedReader br = new BufferedReader(new FileReader(".in"));
PrintWriter out = new PrintWriter(new File(".out"));
StringTokenizer st = new StringTokenizer(br.readLine());
int h = Integer.parseInt(st.nextToken());
int w = Integer.parseInt(st.nextToken());
int grid[][] = new int[h][w];
for(int i = 0; i < h; ++i){
String s = br.readLine();
for(int j = 0; j < w; ++j){
grid[i][j] = s.charAt(j) == 'J' ? 0 : s.charAt(j) == 'O' ? 1 : 2;
}
}
int[][] suffo = new int[h][w];
int[][] suffi = new int[h][w];
for(int i = 0; i < h; ++i){
for(int j = w - 1; j >= 0; --j){
suffo[i][j] = grid[i][j] == 1 ? 1 : 0;
if(j < w - 1) suffo[i][j] += suffo[i][j + 1];
}
}
for(int i = 0; i < w; ++i){
for(int j = h - 1; j >= 0; --j){
suffi[j][i] = grid[j][i] == 2 ? 1 : 0;
if(j < h - 1) suffi[j][i] += suffi[j + 1][i];
}
}
long ans = 0;
for(int i = 0; i < w; ++i){
for(int j = 0; j < h; ++j){
if(grid[i][j] == 0) {
ans += (long) suffo[i][j] * suffi[i][j];
}
}
}
System.out.println(ans);
br.close();
out.close();
}
}
Compilation message
joi2019_ho_t1.java:4: error: class joi2019ho_t1 is public, should be declared in a file named joi2019ho_t1.java
public class joi2019ho_t1 {
^
1 error