import sys


def print_sea_cucumbers(sea_cucumbers, width, height):
    for y in range(height):
        print("".join(sea_cucumbers.get((x, y), ".") for x in range(width)))


def main():
    lines = list(map(str.strip, sys.stdin))

    width = len(lines[0])
    height = len(lines)

    sea_cucumbers = {
        (x, y): c
        for y, line in enumerate(lines)
        for x, c in enumerate(line.strip())
        if c in ">v"
    }

    for step in range(0, sys.maxsize):
        # print()
        # print(step)
        # print()
        # print_sea_cucumbers(sea_cucumbers, width, height)
        # print()

        old_sea_cucumbers = sea_cucumbers

        for dx, dy, c in [(1, 0, ">"), (0, 1, "v")]:
            new_sea_cucumbers = {}

            for (x, y), d in sea_cucumbers.items():
                if d != c:
                    new_sea_cucumbers[x, y] = d
                    continue

                new_x = (x + dx) % width
                new_y = (y + dy) % height

                if (new_x, new_y) in sea_cucumbers:
                    new_sea_cucumbers[x, y] = d
                else:
                    new_sea_cucumbers[new_x, new_y] = d

            sea_cucumbers = new_sea_cucumbers

        if sea_cucumbers == old_sea_cucumbers:
            print(step + 1)
            break


if __name__ == "__main__":
    main()
