using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    public class Point
    {
        public int h;
        public int w;
        public Point(int i, int j)
        {
            h = i;
            w = j;
        }
    }


    class Program
    {
    
        static void Main(string[] args)
        {

            while (true)
            {
                string[] input = Console.ReadLine().Split(' ');
                int W = int.Parse(input[0]);
                int H = int.Parse(input[1]);

                if(H == 0 && W == 0)
                {
                    break;
                }

                char[,] masu = new char[H, W];
                Point start = new Point(0, 0);
                bool[,] visited = new bool[H, W];
                
                for(int i = 0; i < H; i++)
                {
                    string s = Console.ReadLine();

                    for(int j = 0; j < W; j++)
                    {
                        if(s[j] == '@')
                        {
                            start.h = i;
                            start.w = j;
                        }
                        masu[i, j] = s[j];
                    }
                }

                Stack<Point> stack = new Stack<Point>();
                stack.Push(start);
                int reach_num = 1;
                int h = start.h;
                int w = start.w;
                Point now_point;

                while (true)
                {               
                    bool can_go = false;

                    if(h - 1 >= 0 && masu[h - 1, w] == '.' && !visited[h - 1, w])
                    {
                        visited[h - 1, w] = true;
                        reach_num++;
                        stack.Push(new Point(h, w));
                        h--;
                        can_go = true;
                    }
                    else if (h + 1 < H && masu[h + 1, w] == '.' && !visited[h + 1, w])
                    {
                        visited[h + 1, w] = true;
                        reach_num++;
                        stack.Push(new Point(h, w));
                        h++;
                        can_go = true;
                    }
                    else if (w - 1 >= 0 && masu[h, w - 1] == '.' && !visited[h, w - 1])
                    {
                        visited[h, w - 1] = true;
                        reach_num++;
                        stack.Push(new Point(h, w));
                        w--;
                        can_go = true;
                    }
                    else if (w + 1 < W && masu[h, w + 1] == '.' && !visited[h, w + 1])
                    {
                        visited[h, w + 1] = true;
                        reach_num++;
                        stack.Push(new Point(h, w));
                        w++;
                        can_go = true;
                    }

                    if (!can_go)
                    {
                        if(stack.Count == 0)
                        {
                            break;
                        }
                        now_point = stack.Pop();
                        h = now_point.h;
                        w = now_point.w;
                    }

                }

                Console.WriteLine(reach_num);
                
            }
            
        
        }
    }
}


Measured memory_bytes: 16328