Harryxun/stf_run huggingface dataset:
H, W = list(map(int, input().split()))
M = [[-1]*(W+2)]
ans = 0
for _ in range(H):
  s = input()
  ans += s.count('.')
  M.append([-1]+[0 if c=='.' else -1 for c in s]+[-1])
  M += [[-1]*(W+2)]

  queue = [(1,1)]
  M[1][1] = 1
  dr = [(+1,0),(-1,0),(0,+1),(0,-1)]
  turn = 1
  while len(queue)>0:
    turn += 1
    queue_new = []
    for qx, qy in queue:
      for dx, dy in dr:
        x, y = qx+dx, qy+dy
        if M[y][x]==0:
          M[y][x] = turn
          queue_new.append((x,y))
          queue = queue_new

          print(ans-M[H][W] if M[H][W]>0 else -1)

### FIXED CODE ###

H, W = list(map(int, input().split()))
M = [[-1]*(W+2)]
ans = 0
for _ in range(H):
    s = input()
    ans += s.count('.')
    M.append([-1]+[0 if c=='.' else -1 for c in s]+[-1])
M += [[-1]*(W+2)]

queue = [(1,1)]
M[1][1] = 1
dr = [(+1,0),(-1,0),(0,+1),(0,-1)]
turn = 1
while len(queue)>0:
    turn += 1
    queue_new = []
    for qx, qy in queue:
        for dx, dy in dr:
            x, y = qx+dx, qy+dy
            if M[y][x]==0:
                M[y][x] = turn
                queue_new.append((x,y))
    queue = queue_new

print(ans-M[H][W] if M[H][W]>0 else -1)
cnt = 0
n = int(input())
for i int rangr(1, n + 1):
  p = int(input())
  if int(i) != p :
    cnt += 1
    if cnt >= 2:
      break
if cnt <= 1 :
  print("YES")
else :
   print("NO")


### FIXED CODE ###

cnt = 0
n = int(input())
p = list(map(int, input().split()))
for i in range(1, n + 1):
  if int(i) != p[i - 1] :
    cnt += 1
    if cnt >= 3:
      break
if cnt <= 2 :
  print("YES")
else :
   print("NO")
from collections import Counter
 
M = 998244353
n = int(input())
a = map(int, input().split())
x, c = next(a), Counter(a)
r = 0
if x == c[0] == 0:
  r = x = 1
  try:
    for i in range(1, n):
      p = x; x = c.get(i); n -= x
      r = r * pow(p, x, M) % M
  except ValueError:
    pass
print((r, 0)[n > 1])

### FIXED CODE ###

from collections import Counter

M = 998244353
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
if a[0] == 0 and c[0] == 1:
    r = i = 1
    while c[i]:
        r = r * pow(c[i - 1], c[i], M) % M
        n -= c[i]
        i += 1
print(r if n == 1 else 0)
value = int(input())
if value.count(5) ==2:
  if value.count(7) ==1:
    print('YES')
  else:
    print('NO')
else:
  print('NO')
  


### FIXED CODE ###

value = input()
if value.count("5") ==2:
  if value.count("7") ==1:
    print('YES')
  else:
    print('NO')
else:
  print('NO')
N,K=map(int,input().split())#N人K種類
ls=[False for _ in range(N)]
for i in range(K):
  d=int(input())
  A=list(map(int,input().split()))
  for j in range(d):
    ls[A[j]-1]=True
S=0
for i in range(K):
  if ls[i]==False:
    S+=1
print(S)

### FIXED CODE ###

N,K=map(int,input().split())#N人K種類
ls=[False for _ in range(N)]
for i in range(K):
  d=int(input())
  A=list(map(int,input().split()))
  for j in range(d):
    ls[A[j]-1]=True
S=0
for i in range(N):
  if ls[i]==False:
    S+=1
print(S)
n=int(input())
TREE=[[] for _ in range(n)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    a-=1
    b-=1
    TREE[a].append([b,c])
    TREE[b].append([a,c])
q,k=map(int,input().split())
k-=1
depth=[0]*n
visited=[False for i in range(n)]

def DFS(s,d):
    depth[s]=d
    visited[s]=True
    for i in TREE[s]:
        if not visited[i[0]]:
            DFS(i[0],d+i[1])
    return

DFS(k,0)
for i in range(q):
    start,goal=map(int, input().split())
    print(depth[start-1]+depth[goal-1])

### FIXED CODE ###

import heapq
import itertools
n=int(input())
edges=[[] for _ in range(n)]
for _ in range(n-1):
    a,b,c=map(int, input().split())
    a,b=a-1,b-1
    edges[a].append((b,c))
    edges[b].append((a,c))

def dijkstra(x,route):
    d=[float('inf')]*n
    d[x]=0
    visited={x}
    hq=[(0,x)]
    while hq:
        u=heapq.heappop(hq)[1]
        visited.add(u)
        for node,cost in route[u]:
            if (node not in visited) and d[node]>d[u]+cost:
                d[node]=d[u]+cost
                heapq.heappush(hq,(d[node],node))
    return d
q,k=map(int,input().split())
k-=1
dist=dijkstra(k,edges)
for _ in range(q):
    start,goal=map(int,input().split())
    print(dist[start-1]+dist[goal-1])
import math

def permutation(n,k):
    return math.factorial(n)//math.factorial(n-k)

if __name__=="__main__":
    num_vertax,num_coler=map(int,input().split())
    ver_array=[[i+1,[]] for i in range(num_vertax)]
    for i in range(num_vertax-1):
        a,b=map(int,input().split())
        ver_array[a-1][1].append(ver_array[b-1][0])
        ver_array[b-1][1].append(ver_array[a-1][0])
    ans=num_coler
    top=1
    for ver in ver_array:
        ans*=permutation(num_coler-top,len(ver[1])+1-top)
        top=2
    print(ans%1000000007)

### FIXED CODE ###

N,K=map(int,input().split())
mod=1000000007
path=[[] for i in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  a=a-1
  b=b-1
  path[a].append(b)
  path[b].append(a)
#print(path)
  
abc=[False for i in range(N)] #0ならまだ塗ってない
 
abc[0]=True
cnt=0
ans=K%mod
nx=[]
for i in range(len(path[0])):
  child=path[0][i]
  if abc[child]:
    continue
  ans=ans*(K-1-cnt)
  ans=ans%mod
  cnt=cnt+1
  abc[child]=True
  nx.append(child)
while len(nx)>0:
  a=nx.pop()
  cnt=0
  for i in range(len(path[a])):
    child=path[a][i]
    if abc[child]:
      continue
    ans=ans*(K-2-cnt)
    ans=ans%mod
    cnt=cnt+1
    abc[child]=True
    nx.append(child)
      
print(ans%mod)
# -*- coding: utf-8 -*-
a = int(input())
total = 0
for _ in range(a):
    i = input()
    v,c = i.split()
    v = int(v)
    if(c=="BTC"):
        v *= 380000
    total += v
print(total)


### FIXED CODE ###

a = int(input())
total = 0
for _ in range(a):
    i = input()
    v,c = i.split()
    v = float(v)
    if(c=="BTC"):
        v *= 380000
    total += v
print(total)
import sys
import time
def input():
    return sys.stdin.readline()[:-1]
h,w=map(int,input().split())
a=[list(map(int,input().split())) for i in range(h)]
b=[list(map(int,input().split())) for i in range(h)]
kata=[]
for i in range(h):
    tmp=[]
    for j in range(w):
        tmp.append(abs(a[i][j]-b[i][j]))
    kata.append(tmp)
# print(kata)
tmp=0
for i in range(h):
    tmp=max(tmp,max(kata[i]))
# print(tmp)

dp=[[[0 for i in range(tmp*(h+w)+1)] for j in range(w+1)] for k in range(h+1)]
dp[0][0][kata[0][0]]+=1
i=0
j=0
# print(dp)
while i+j!=h+w-2:
    # print(i,j)
    for k in range(tmp*(h+2)+1):
        if dp[i][j][k]!=0:
            if i+1!=h:
                dp[i+1][j][k+kata[i+1][j]]+=1
                dp[i+1][j][abs(k-kata[i+1][j])]+=1
            if j+1!=w:
                dp[i][j+1][k+kata[i][j+1]]+=1
                dp[i][j+1][abs(k-kata[i][j+1])]+=1
    i-=1
    j+=1
    if i<0:
        i=abs(i+j)+1
        j=0
    while i>=h:
        i-=1
        j+=1
    # time.sleep(1)
# print(dp[1][0])
# print(dp[0][1])
# print(dp[h-1][w-1])
for i in range(tmp*(h+w)+1):
    if dp[h-1][w-1][i]!=0:
        print(i)
        quit()

### FIXED CODE ###

import sys

input = sys.stdin.buffer.readline

h, w = map(int, input().split())
AA = [list(map(int, input().split())) for _ in range(h)]
BB = [list(map(int, input().split())) for _ in range(h)]

kouho = [[0] * (w) for _ in range(h)]
delta = abs(AA[0][0] - BB[0][0])
kouho[0][0] |= 1 << delta
for y in range(h):
    for x in range(w):
        nx = x + 1
        ny = y
        if nx < w:
            delta = abs(AA[ny][nx] - BB[ny][nx])
            temp = 0
            for i in range(1, delta + 1):
                if (kouho[y][x] >> i) % 2:
                    temp |= 1 << (delta - i)
            # print(x,y,kouho[y][x],temp,delta)
            kouho[ny][nx] |= kouho[y][x] << delta
            kouho[ny][nx] |= kouho[y][x] >> delta
            kouho[ny][nx] |= temp

        nx = x
        ny = y + 1
        if ny < h:
            delta = abs(AA[ny][nx] - BB[ny][nx])
            temp = 0
            for i in range(1, delta + 1):
                if (kouho[y][x] >> i) % 2:
                    temp |= 1 << (delta - i)
            # print(x,y,kouho[y][x],temp,delta)
            kouho[ny][nx] |= kouho[y][x] << delta
            kouho[ny][nx] |= kouho[y][x] >> delta
            kouho[ny][nx] |= temp
# print(kouho)
for i in range(81):
    if (kouho[h - 1][w - 1] >> i) % 2:
        print(i)
        exit()
n=int(input())
dat = list(map(int, input().split()))

flag=True
count = 0

while flag==True:
     for i in range(n):
         if dat[i]%2==1:
             flag=False
              break
          else:
              dat[i] = dat[i]/2
       count = count+1

print(count)
         


 
      
      
             


    
    
     
                

         
           




### FIXED CODE ###

import sys

def main():
    N = int(input())
    A = [int(_) for _ in input().split()]

    t = 0
    while True:
        for i in range(N):
            if A[i] % 2 == 0:
                A[i] //= 2
            else:
                print(t)
                sys.exit()
        t += 1

main()
A,B = (int(i) for i in input().split())

import math

def lcm(a, b):
    return a * b // math.gcd (a, b)

print(lcm(A,B))

### FIXED CODE ###

A,B = (int(i) for i in input().split())

import fractions

def lcm(a, b):
    #return a * b // math.gcd(a, b)
    return  a*b // fractions.gcd(a, b)

print(lcm(A,B))
s = str(input())

if (s[0] == s[1] and s[2] == s[3])or(s[0] == s[2] and s[1] == s[3])or(s[0] == s[3] and s[1] == s[2]):
  print(Yes)
elif s[0] == s[1] and s[0] == s[2] and s[0] == s[3]:
  print(No)
else:
   print(No)

### FIXED CODE ###

s = str(input())

if (s[0] == s[1]) and (s[2] == s[3]) and (s[1] == s[2]):
  print('No')
elif (s[0] == s[1]) and (s[2] == s[3]):
  print('Yes')
elif (s[0] == s[2]) and (s[1] == s[3]):
  print('Yes')
elif (s[0] == s[3]) and (s[2] == s[1]):
  print('Yes')
else:
  print('No')
A,B,C,K = map(int,input().split())
if A + B >= K:
	print(max(K.A))
else:
	print(A-(K-(A+B)))

### FIXED CODE ###

A,B,C,K = map(int,input().split())
if A + B >= K:
	print(min(K,A))
else:
	print(A-(K-(A+B)))
from functools import reduce
from operators import mul
 
n = int(input())
a = list(map(int, input().strip()))
 
m = reduce(mul, a) - 1
ans = 0
for ai in a:
  ans += m % ai
 
print(ans)


### FIXED CODE ###

from functools import reduce
from operator import mul
n = int(input())
a = list(map(int, input().split()))

m = reduce(mul, a) - 1
ans = 0
for ai in a:
    ans += m % ai
print(ans)
import math
a,b = map(str, input().split())
a = int(a)
b = b.replace(".","")
if len(b) == 2:
    b = b + '0'
b = int(b)
ans = a*b
if ans == 0:
    print(0)
else:
    print(int(str(ans)[:-2]))

### FIXED CODE ###

import math
a,b = map(str, input().split())
a = int(a)
b = b.replace(".","")
if len(b) == 2:
    b = b + '0'
b = int(b)
ans = a*b
if len(str(ans)) <= 2:
    print(math.floor(ans/100))
else:
    print(int(str(ans)[:-2]))
n = int(input())
obj= []
for i in range (n):
	obj.append(input())
dictOfElems = dict()
for elem in obj:
  if elem in dictOfElems:
    dictOfElems[elem] += 1
  else:
    dictOfElems[elem] = 1
print(len(dict))

### FIXED CODE ###

n = int(input())
obj= []
for i in range (n):
	obj.append(input())
dictOfElems = dict()
for elem in obj:
  if elem in dictOfElems:
    dictOfElems[elem] += 1
  else:
    dictOfElems[elem] = 1
print(len(dictOfElems))
N,K = map(int, input().split())
A =[0]
B=list(map(int, input().split()))
for m in range(N):
    A.append(B[m])
place=set([])
p=[]
i=1
count=0
while i not in place:
    place.add(i)
    p.append(i)
    i=A[i]
    count+=1
if count>=K:
    print(p[K])
else:
    loop=[i]
    start=i
    j=A[i]
    count+=1
    while j!=start:
        loop.append(j)
        j=A[j]
        count+=1
    num=(K-count)%len(loop)
    print(loop[num])

### FIXED CODE ###

N,K = map(int, input().split())
A =[0]
B=list(map(int, input().split()))
for m in range(N):
    A.append(B[m])
place=set([])
p=[]
i=1
count=0
while i not in place:
    place.add(i)
    p.append(i)
    i=A[i]
    count+=1
if count>K:
    print(p[K])
else:
    loop=[i]
    start=i
    j=A[i]
    count+=1
    while j!=start:
        loop.append(j)
        j=A[j]
        count+=1
    if count>K:
        print(loop[K-len(p)])
    else:
        num=(K-count)%len(loop)
        print(loop[num])
import sys
from collections import defaultdict


class UnionFindPathCompression():
    def __init__(self, n):
        self.parents = list(range(n))

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        self.parents[y] = x


N, M = map(int, input().split())
uf = UnionFindPathCompression(N)

for i in range(M):
    A, B = map(int, input().split())
    uf.union(A - 1, B - 1)

hoge = [uf.find(i) for i in range(N)]

d = defaultdict(int)
for key in hoge:
    d[key] += 1

# print(d.values())
print(max(d.values()))


### FIXED CODE ###

import sys
from collections import defaultdict
import collections

sys.setrecursionlimit(1000000)

class UnionFindPathCompression():
    def __init__(self, n):
        self.parents = list(range(n))

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        self.parents[y] = x


N, M = map(int, input().split())
uf = UnionFindPathCompression(N)

for i in range(M):
    A, B = map(int, input().split())
    uf.union(A - 1, B - 1)

hoge = [uf.find(i) for i in range(N)]

#print(hoge)
hogehoge = collections.Counter(hoge).most_common()

print(hogehoge[0][1])
# 二次元累積和
# A[i1, j1] から A[i2, j2] までの長方形の積算値は
# Acum[i2 + 1][j2 + 1] - Acum[i1][j2 + 1] - Acum[i2 + 1][j1] + Acum[i1][j1]
def two_dim_accumulate(a) -> list:
  h, w = len(a), len(a[0])
  acum = [[0 for _ in range(h + 1)] for _ in range(w + 1)]
  for i in range(h):
    for j in range(w):
      acum[i + 1][j + 1] = a[i][j]
  for i in range(1, h + 1):
    for j in range(1, w + 1):
      acum[i][j] += acum[i][j - 1]
  for j in range(1, w + 1):
    for i in range(1, h + 1):
      acum[i][j] += acum[i - 1][j]
  return acum

Acum = two_dim_accumulate(A)
Acum[q][q] - Acum[p - 1][q] - Acum[q][p - 1] + Acum[p - 1][p - 1]


### FIXED CODE ###

A,B=map(int,input().split())
print((A-1)*(B-1))
hoge = input()
print(hoge ** 3)

### FIXED CODE ###

input_lines = int(input())
print(input_lines **3)
https://atcoder.jp/contests/abc128/tasks/abc128_a

### FIXED CODE ###

Str = list(input())
tmp = 0
maxLen = 0

for s in Str:
    if s in "ACGT":
        tmp += 1
        maxLen = max(maxLen, tmp)
    else:
        tmp = 0


print(maxLen)
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if a = b:
  print('YES')
elif a < b:
  if b - w * t <= a - v * t:
    print('YES')
  else:
    print('NO')
else:
  if a + v * t <= b + w * t:
    print('YES')
  else:
	  print('NO')
  


### FIXED CODE ###

a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if a == b:
  print('YES')
elif a < b:
  if b + w * t <= a + v * t:
    print('YES')
  else:
    print('NO')
else:
  if a - v * t <= b - w * t:
    print('YES')
  else:
	  print('NO')
from sys import stdin
input = stdin.readline

X,K,D = map(int, input().split())
X=abs(X)
if(X>K*D):
  print(X-K*D)
elif(X>=D):
  m = X % D
  q = X//D
  K = K-q
  if(K==0):
    print(m)
  elif(m>abs(m-D) or K%2==1):
    print(abs(m-D))
  else:
    print(m)
else:
  if(K%2==1):
    print(abs(m-D))
  else:
    print(X)
  
    

### FIXED CODE ###

from sys import stdin
input = stdin.readline

X,K,D = map(int, input().split())
X=abs(X)
if(X>K*D):
  print(X-K*D)
elif(X>=D):
  m = X % D
  q = X//D
  K = K-q
  if(K==0):
    print(m)
  elif(K%2==1):
    print(abs(m-D))
  else:
    print(m)
else:
  if(K%2==1):
    print(abs(X-D))
  else:
    print(X)
class UnionFind:
    def __init__(self, n):
        self.root = list(range(n + 1))
        self.size = [1] * (n + 1)

    def find(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        sx, sy = self.size[x], self.size[y]
        if sx < sy:
            self.root[x] = y
            self.size[y] += sx
        else:
            self.root[y] = x
            self.size[x] += sy


n, m = map(int, input().split())
p = np.array(list(map(int, input().split())))


uf = UnionFind(n)
union = uf.union
find = uf.find


for _ in range(m):
    x, y = map(int, input().split())
    union(x - 1, y - 1)

ans = 0
for i, x in enumerate(p):
    if find(i) == find(x - 1):
        ans += 1

print(ans)

### FIXED CODE ###

class UnionFind:
    def __init__(self, n):
        self.root = list(range(n + 1))
        self.size = [1] * (n + 1)

    def find(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        sx, sy = self.size[x], self.size[y]
        if sx < sy:
            self.root[x] = y
            self.size[y] += sx
        else:
            self.root[y] = x
            self.size[x] += sy


n, m = map(int, input().split())
p = list(map(int, input().split()))


uf = UnionFind(n)
union = uf.union
find = uf.find


for _ in range(m):
    x, y = map(int, input().split())
    union(x - 1, y - 1)

ans = 0
for i, x in enumerate(p):
    if find(i) == find(x - 1):
        ans += 1

print(ans)
input()
A = list(map(int,input().split()))

if A.count(5) == 2 and A.count(7) == 1 :
  print("YES")
  
else :
  print("NO")

### FIXED CODE ###

A = list(map(int,input().split()))

if A.count(5) == 2 and A.count(7) == 1 :
  print("YES")
  
else :
  print("NO")
import math

def main():

    # 1 <= a <= b <= 10^18
    # 1 <= c,d <= 10^9

    a, b, c, d = map( int, input().split())
    count = 0

    ac = -(-a // c)
    bc = b // c

    ad = -(-a // d)
    bd = b // d

    cd = int(c * d / math.gcd(c, d))

    acd = -(-a // cd)
    bcd = b // cd

    cm_num = bc - ac + 1
    dm_num = bd - ad + 1
    cdm_num = bcd - acd + 1

    count = cm_num + dm_num - cdm_num

    total = b - a + 1

    print(total - count)

if __name__ == '__main__':
    main()



### FIXED CODE ###

#import math
import fractions

def main():

    # 1 <= a <= b <= 10^18
    # 1 <= c,d <= 10^9

    a, b, c, d = map( int, input().split())
    count = 0

    ac = -(-a // c)
    bc = b // c

    ad = -(-a // d)
    bd = b // d

    cd = int(c * d / fractions.gcd(c, d))

    acd = -(-a // cd)
    bcd = b // cd

    cm_num = bc - ac + 1
    dm_num = bd - ad + 1
    cdm_num = bcd - acd + 1

    count = cm_num + dm_num - cdm_num

    total = b - a + 1

    print(total - count)

if __name__ == '__main__':
    main()
[print(["YES", "NO"][0 if int(i[0]) ** 2 + int(i[1]) ** 2 == int(i[2]) ** 2 else 1]) for i in sorted([int(x) for x in input().split()]) for _ in range(int(input()))]

### FIXED CODE ###

[print("YES" if i[0] + i[1] == i[2] else "NO") for _ in range(int(input())) for i in [sorted([int(x) ** 2 for x in input().split()])]]
def insertion_sort(target_list, leng):
    sorted_list = [target_list.pop(0)]
    for target in target_list[:]:
        print(('{} ' * (leng - 1)).format(*sorted_list,
                                          *target_list[0:-1]), end='')
        print(target_list[-1])
        for i, num in enumerate(sorted_list):
            if num > target:
                sorted_list[i:i] = [target]
                break
        else:
            sorted_list.append(target)
        target_list.pop(0)
    print(('{} ' * (N - 1)).format(*sorted_list[0:-1]), end='')
    print(sorted_list[-1], end='')

N = int(input())
A = [int(s) for s in input().split()]
insertion_sort(A, N)

### FIXED CODE ###

def insertion_sort(target_list):
    sorted_list = list()
    for target in target_list[:]:
        for i, num in enumerate(sorted_list):
            if num > target:
                sorted_list[i:i] = [target]
                break
        else:
            sorted_list.append(target)
        target_list.pop(0)
        print(' '.join(str(s) for s in sorted_list + target_list))

N = int(input())
A = [int(s) for s in input().split()]
insertion_sort(A)
x1, y1, x2, y2 = map(int, input().split())
 
x3 = x2 + (y1 - y2)
y3 = y2 - (x1 - x2)
x4 = x3 + (x1 - x2)
y4 = y3 + (y1 - y2)
 
print(x3, y3, x4, y4)

### FIXED CODE ###

a = int(input())

oddl = []
evenl = []

for i in range(a):
    if i%2 == 1:
        oddl.append(i)
    else:
        evenl.append(i)

odd = len(oddl)
even = len(evenl)

print(odd*even)
N, A, B = map(int, input().split())
 ans = N // (A + B) * A
 rem = N % (A + B)
 ans += min(rem, A)
 print(ans)


### FIXED CODE ###

N, A, B = map(int, input().split())
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)
H,W = map(int,input().split())
S = list(input() for i in range(H))
Grid1 = [[0]*W for i in range(H)]
#print(S)
ans = 0
for i in range(H):
    cou = 0
    piyo = 0
    hoge = [0]*H
    for j in range(W):
        #print(i,j,S[i][j])
        if S[i][j] == ".":
            cou += 1
        else:
            hoge[piyo]= cou
            piyo += 1
            cou = 0
    hoge[piyo] = cou
    ws = []
    for j in hoge[:piyo+1]:
        ws = ws+[j]*j+[0]
    #print(ws,ws[:-1])
    Grid1[i] = ws[:-1]

for i in range(W):
    cou = 0
    piyo = 0
    hoge = [0]*W
    for j in range(H):
        #print(i,j,S[i][j])
        if S[j][i] == ".":
            cou += 1
        else:
            hoge[piyo]=cou
            piyo+=1
            cou = 0
    hoge[piyo] = (cou)
    ws = []
    for j in hoge[:piyo+1]:
        ws = ws+[j]*j+[0]
    #print(ws,ws[:-1])
    for j in range(H):
        ans =max(Grid1[j][i] +ws[j], ans)

print(ans-1)

### FIXED CODE ###

H,W = map(int,input().split())
S = list(input() for i in range(H))
Grid1 = [[0]*W for i in range(H)]
for i in range(H):
    cou = 0
    l = 0
    for j in range(W):
        if S[i][j] == ".":
            cou += 1
        else:
            for x in range(l,j):
                Grid1[i][x] = cou
            l = j+1
            cou = 0
    for x in range(l,j+1):
        Grid1[i][x] = cou    
for i in range(W):
    cou = 0
    l = 0
    for j in range(H):
        #print(i,j,S[i][j])
        if S[j][i] == ".":
            cou += 1
        else:
            for x in range(l,j):
                Grid1[x][i] += cou
            l = j+1
            cou = 0
    for x in range(l,j+1):
        Grid1[x][i] += cou

print(max(max(Grid1[i]) for i in range(H))-1)
S = input()
T = input()
D = []
for i in range(len(S) - len(T)):
    SS = S[i:i+len(T)]
    dif = 0
    for j in range(len(T)):
        if T[j] != SS[j]:
            dif += 1
    D += [dif]
            
print(min(D))


### FIXED CODE ###

S = input()
T = input()
D = []
for i in range(len(S) - len(T) + 1):
    SS = S[i:i+len(T)]
    dif = 0
    for j in range(len(T)):
        if T[j] != SS[j]:
            dif += 1
    D += [dif]
            
print(min(D))
N=int(input())
A=list(map(int,input().split()))
print(max(A)-max(B))

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
m1=max(A)
m2=min(A)
print(m1-m2)
import math

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
    if i != n // i:
      divisors.append(n//i)
      return divisors

num = int(input())
print(make_divisors(math.factorial(num)) % (pow(10,9) + 7))

### FIXED CODE ###

import math
import collections

def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    factor.append(n)
    return factor

n = int(input())
c = collections.Counter([])
for num in range(2, n+1):
  prime_list = trial_division(num)
  c.update(prime_list)
res = 1
for prime, count in c.most_common():
  if(prime > 1):
    res = res * (count + 1)
print(res % (pow(10,9) + 7))