Go: package main

import (
	"bufio"
	"encoding/json"
	"fmt"
	"os"
	"strconv"
	"strings"
)

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

type Color int

const (
	ColorBlack Color = iota
	ColorRed
)

var strByColor = map[Color]string{
	ColorBlack: "black",
	ColorRed:   "red",
}

func (c Color) String() string {
	return strByColor[c]
}

type Node struct {
	ID      int
	X, Y    int
	Color   Color
	NextIDs map[int]struct{}
}

func (n *Node) String() string {
	d, _ := json.Marshal(n)
	return string(d)
}

type Map struct {
	Width, Height int
	Nodes         map[int]*Node
}

func (m *Map) GetByID(id int) *Node {
	return m.Nodes[id]
}

func (m *Map) Get(x, y int) *Node {
	return m.Nodes[m.getID(x, y)]
}

func (m *Map) SetColor(x, y int, c Color) {
	m.Nodes[m.getID(x, y)].Color = c
}

func (m *Map) getID(x, y int) int {
	return x + y*m.Width
}

func (m *Map) init() {
	for x := 1; x <= m.Width; x++ {
		for y := 1; y <= m.Height; y++ {
			id := m.getID(x, y)
			m.Nodes[id] = &Node{ID: id, X: x, Y: y}
		}
	}
	for x := 1; x <= m.Width; x++ {
		for y := 1; y <= m.Height; y++ {
			nextIDs := map[int]struct{}{}
			if x > 1 {
				nextIDs[m.getID(x-1, y)] = struct{}{}
			}
			if x < m.Width {
				nextIDs[m.getID(x+1, y)] = struct{}{}
			}
			if y > 1 {
				nextIDs[m.getID(x, y-1)] = struct{}{}
			}
			if y < m.Height {
				nextIDs[m.getID(x, y+1)] = struct{}{}
			}
			m.Get(x, y).NextIDs = nextIDs
		}
	}
}

func NewMap(w, h int) *Map {
	m := &Map{Width: w, Height: h, Nodes: map[int]*Node{}}
	m.init()
	return m
}

type Searcher struct {
	Map        *Map
	queue      []*Node
	touchedIDs map[int]struct{}
	visitedIDs map[int]struct{}
}

func NewSearcher(m *Map) *Searcher {
	return &Searcher{
		Map:        m,
		queue:      []*Node{},
		touchedIDs: map[int]struct{}{},
		visitedIDs: map[int]struct{}{},
	}
}

func (s *Searcher) Search(start *Node) {
	s.enqueue(start)

	for {
		if len(s.queue) == 0 {
			break
		}
		for nextID := range s.dequeue().NextIDs {
			n := s.Map.GetByID(nextID)
			if n.Color == ColorRed || s.hasTouched(n) {
				continue
			}
			s.enqueue(n)
		}
	}
}

func (s *Searcher) VisitedNodeCount() int {
	return len(s.visitedIDs)
}

func (s *Searcher) hasTouched(n *Node) bool {
	_, ok := s.touchedIDs[n.ID]
	return ok
}

func (s *Searcher) enqueue(n *Node) {
	s.queue = append(s.queue, n)
	s.touchedIDs[n.ID] = struct{}{}
}

func (s *Searcher) dequeue() *Node {
	n := s.queue[0]
	s.queue = s.queue[1:]
	s.visitedIDs[n.ID] = struct{}{}
	return n
}

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])

		m := NewMap(w, h)

		// Set colors
		var start *Node
		for y := 1; y <= h; y++ {
			sc.Scan()
			for i, c := range sc.Text() {
				switch c {
				case '.', '@':
					m.SetColor(i+1, y, ColorBlack)
					if c == '@' {
						start = m.Get(i+1, y)
					}
				case '#':
					m.SetColor(i+1, y, ColorRed)
				}
			}
		}

		// Search
		s := NewSearcher(m)
		s.Search(start)
		fmt.Println(s.VisitedNodeCount())
	}
}

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
    first = True
    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
        if first:
            first = False
        else:
            print('')
        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)
        import ipdb;ipdb.set_trace()
        print(move_point)

Python: data, res = [], 0

def valid(x, y):
    global data
    return 0 <= x < W and 0 <= y < H and data[y][x] != '#'

def dfs(x, y):
    global data, res
    if valid(x, y):
        res += 1
        data[y][x] = '#'
        dx = [1, 0, -1, 0]
        dy = [0, 1, 0, -1]
        for i in range(4):
            dfs(x + dx[i], y + dy[i])
    else:
        return
    
while True:
    global data, res
    W, H = map(int, input().split())
    if not W:
        break
    data = [list(input()) for _ in range(H)]
    res = 0
    for i in range(W):
        for j in range(H):
            if data[j][i] == '@':
                dfs(i, j)
                break
    print(res)

Python: c = 0
def calc(t, X, Y):
    global c
    c += 1
    t[Y][X] = '#'
    for x, y in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
        if t[Y + y][X + x] == '.':
            calc(t, X + x, Y + y)
            
while True:
    c = 0
    w, h = map(int, input().split())
    if w == h == 0:
        break
    
    t = [['#'] * (w + 2) ] + [['#'] + list(input()) + ['#'] for _ in range(h)] + [['#'] * (w + 2)]
    for sy in range(h + 2):
        if '@' in t[sy]:
            sx = t[sy].index('@')
            break
      
    calc(t, sx, sy)
    print(c)

Python: #2:52
import sys

sys.setrecursionlimit(10000000)


dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]



#左上からせめて深さ優先で探索する問題
while True:
    # 地図作る
    width,hight = map(int,input().split())
    if width ==0 :
        break
    d =[]
    for _ in range(hight):
        d.append(list(input()))
    
    def dfs(x, y):
    # いまたどり着いたはずなので1に塗りつぶす
        d[y][x]="d"

    #4方向ループ
    #あくまで方向の表し方dxは
        for i in range(4):
            ny = y + dx[i]
            nx = x + dy[i]

        #行ったことがなくって、迷路の範囲内で、障害物がなければ、進む
            if 0 <= ny and ny < hight \
              and 0 <= nx and nx < width \
              and d[ny][nx] == ".":
                dfs(nx,ny) 

    


    for y in range(hight):
        for x in range(width):
            if d[y][x] == "@":
                dfs(x,y)
    
    sum = 0 
    for _ in range(hight):
        sum = sum + d[_].count('d')
    print(sum)

Python: vec = [[1,0],[0,1],[-1,0],[0,-1]]

def dfs(nw,nh):
    global count
    count += 1
    visited[nh][nw] = True
    for x,y in vec:
        new_w = nw + x
        new_h = nh + y
        if (0 <= new_w) and (new_w) < w:
            if (0 <= new_h) and (new_h) < h:
                if (lis_f[new_h][new_w] == ".") and (visited[new_h][new_w] == False):
                    dfs(new_w,new_h)
                    
while(True):
    w,h = map(int,input().split())
    if (w,h) == (0,0):
        break
    lis_f = []
    for _ in range(h):
        lis_f.append(list(input()))
    
    visited = [[False for _ in range(w)] for _ in range(h)]
    count = 0
    
    id_w = 0
    id_h = 0
    set_w = 0
    set_h = 0
    while(id_h < h):
        while(id_w < w):
            #print(lis_f[id_h][id_w])
            if lis_f[id_h][id_w] == "@":
                set_w = id_w
                set_h = id_h
            id_w += 1
        id_h += 1
        id_w = 0
    
    #print(set_w,set_h)
    
    dfs(set_w,set_h)
    print(count)