Each of the squares in a $2 \times 2018$ grid is to be colored black or white such that in any $2 \times 2$ block, at least one of the four squares is white. Let $P$ be the number of ways of coloring the grid. Find the largest $k$ such that $3^k$ divides $P$.

Let's think step by step and output the final answer within \boxed{}.
user