Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

type Color int

const (
	ColorBlack Color = iota
	ColorRed
)

type Node struct {
	ID    int
	X, Y  int
	Color Color
	Nexts []*Node
}

func main() {
	for sc.Scan() {
		if sc.Text() == "0 0" {
			break
		}
		chunks := strings.Split(sc.Text(), " ")
		w, _ := strconv.Atoi(chunks[0])
		h, _ := strconv.Atoi(chunks[1])

		// Initialize map
		m := map[int]map[int]*Node{}
		for x := 1; x <= w; x++ {
			m[x] = map[int]*Node{}
			for y := 1; y <= h; y++ {
				m[x][y] = &Node{ID: x + y*w, X: x, Y: y}
			}
		}
		for x := 1; x <= w; x++ {
			for y := 1; y <= h; y++ {
				nexts := []*Node{}
				if n, ok := m[x-1][y]; ok {
					nexts = append(nexts, n)
				}
				if n, ok := m[x][y-1]; ok {
					nexts = append(nexts, n)
				}
				if n, ok := m[x+1][y]; ok {
					nexts = append(nexts, n)
				}
				if n, ok := m[x][y+1]; ok {
					nexts = append(nexts, n)
				}
				m[x][y].Nexts = nexts
			}
		}

		// Set colors
		queue := []*Node{}
		touchedIDs := map[int]struct{}{}
		for y := 1; y <= h; y++ {
			sc.Scan()
			for i, c := range sc.Text() {
				switch c {
				case '.', '@':
					n := m[i+1][y]
					n.Color = ColorBlack
					if c == '@' {
						queue = append(queue, n)
						touchedIDs[n.ID] = struct{}{}
					}
				case '#':
					m[i+1][y].Color = ColorRed
				}
			}
		}

		// Search
		visitedIDs := map[int]struct{}{}
		for {
			if len(queue) == 0 {
				break
			}
			n := queue[0]
			queue = queue[1:]
			visitedIDs[n.ID] = struct{}{}
			for _, next := range n.Nexts {
				if next.Color == ColorRed {
					continue
				}
				if _, ok := touchedIDs[next.ID]; !ok {
					queue = append(queue, next)
					touchedIDs[n.ID] = struct{}{}
				}
			}
		}
		fmt.Println(len(visitedIDs))
	}
}

Python: 

def search(a,b,dx,dy,t,check,li,answer):
    for i in range(len(dx)):
            temp = [t[0]+dx[i],t[1]+dy[i]]
            if mapCheck(a,b,temp):
                if check[temp[1]][temp[0]] == 0:
                    if li[temp[1]][temp[0]] == '.':
                        answer += 1
                        check[temp[1]][temp[0]] = 1
                        answer = search(a,b,dx,dy,temp,check,li,answer)
    return answer
                    
                
            
def mapCheck(a,b,t):
    if t[0] <= a-1 and t[0] >=0:
        if t[1] <= b-1 and t[1] >= 0:
            return True
    return False

while True:
    li = []
    answer = 1
    start = [0,0]
    a,b = map(int, input().strip().split(' '))
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    if a == 0 and b == 0:
        break
    for i in range(b):
        li.append(input().strip().split())
    check = [[0 for i in range(a)] for j in range(b)]
    for i in range(len(li)):
        li[i] = str(li[i])
        li[i] = list(li[i])
        del li[i][0]
        del li[i][0]
        del li[i][len(li[i])-1]
        del li[i][len(li[i])-1]
        for j in range(len(li[i])):
            if li[i][j] == '@':
                start = [j,i]
    print(search(a,b,dx,dy,start,check,li,answer))

Python: from queue import Queue

while True:
    w, h = map(int, input().split())
    if w == h == 0:
        break

    tile = [input() for i in range(h)]
    for x, col in enumerate(tile):
        if '@' in col:
            y = col.index('@')
            s = (x, y)
            break

    visit = [[False for i in range(w)] for j in range(h)]
    dx = (0, -1, 1, 0)
    dy = (1, 0, 0, -1)
    que = Queue()
    que.put(s)
    while not que.empty():
        x, y = que.get()
        if visit[x][y]:
            continue

        visit[x][y] = True
        for j in range(4):
            sx = x + dx[j]
            sy = y + dy[j]
            if sx < 0 or sx >= h or sy < 0 or sy >= w:
                continue
            if tile[sx][sy] != '#':
                que.put((sx, sy))

    ans = 0
    for col in visit:
        ans += col.count(True)

    print(ans)

Python: from collections import defaultdict
def explore(now,cnt):
    if cnt>W*H:#理論的にはW*H以下で全部回れるので
        a=0 #無駄なコード
    else:
        d[now]=1
        if now[1]+1<W:
            if not data[now[0]][now[1]+1]=="#":
                if not (now[0],now[1]+1) in d.keys():
                    explore((now[0],now[1]+1),cnt+1)
        if now[0]+1<H:
            if not data[now[0]+1][now[1]]=="#":
                if not (now[0]+1,now[1]) in d.keys():
                    explore((now[0]+1,now[1]),cnt+1)
        if now[0]-1>=0:
            if not data[now[0]-1][now[1]]=="#":
                if not (now[0]-1,now[1]) in d.keys():
                    explore((now[0]-1,now[1]),cnt+1)
        if now[1]-1>=0:
            if not data[now[0]][now[1]-1]=="#":
                if not (now[0],now[1]-1) in d.keys():
                    explore((now[0],now[1]-1),cnt+1)
    
while True:
    W,H=map(int,input().split())
    if W==0 and H==0:
        break
    data=[list(input()) for _ in range(H)]
    d=defaultdict()
    for i in range(H):
        for j in range(W):
            if data[i][j]=="@":
                start=(i,j)
                break
    now=start
    cnt=0
    explore(now,cnt)
    print(len(d.keys()))

Python: 
def depth_first_search(x, y):
    """
    ??±???????????¢?´¢?????????
    :param x: ?????¨??°????¨?
    :param y: ?????¨??°??????
    :return: ?????°
    """

    # ????????????????????§?¢??????????
    # ??????x  ,y+1
    # ??????x+1,y
    # ??????x  ,y-1
    # ??????x-1,y
    move_list = [[0,1],[1,0],[0,-1],[-1,0]]
    for i in range(0,4,1):
        next_x = x+move_list[i][0]
        next_y = y+move_list[i][1]
        # tile_map??????????§??????§????????´??????'.'???
        if 0 <= next_x and 0 <= next_y and \
            next_x < W and next_y < H and \
            tile_map[next_y][next_x] != '#':

            # ?§?????????????????????¨??°????§??????§??????????????????"#"??????????????????
            tile_map[y][x] = '#'
            import __main__
            __main__.move_point = __main__.move_point+1
            depth_first_search(next_x, next_y)

def get_start_point(tile_map):
    """
    @????????????????????????
    :param tile_map:
    :return:
    """
    for i, y in enumerate(tile_map):
        for j, x in enumerate(y):
            if x == '@':
                return i, j



if __name__ == "__main__":
    move_point = 0
    while (True):
        # input_1 : tile????????????
        tile_size = input('').split(' ')
        W, H = [int(x) for x in tile_size]
        if W == 0 and H == 0:
            break
        tile_map=[''] * H
        for i in range(0, H, 1):
            # input_2 : tile???????????????????????????
            map_line = list(input(''))
            tile_map[i] = map_line
        start_H, start_W = get_start_point(tile_map)
        depth_first_search(start_W, start_H)
        print(move_point)