Let $n> 2$ be a positive integer. Given is a horizontal row of $n$ cells where each cell is painted blue or red. We say that a block is a sequence of consecutive boxes of the same color.  Arepito the crab is initially standing at the leftmost cell. On each turn, he counts the number $m$ of cells belonging to the largest block containing the square he is on, and does one of the following:

If the square he is on is blue and there are at least $m$ squares to the right of him, Arepito moves $m$ squares to the right;

If the square he is in is red and there are at least $m$ squares to the left of him, Arepito moves $m$ cells to the left; 

In any other case, he stays on the same square and does not move any further.  

For each $n$, determine the smallest integer $k$ for which there is an initial coloring of the row with $k$ blue cells, for which Arepito will reach the rightmost cell. 
To solve this problem, we need to determine the smallest number of blue cells, \( k \), such that Arepito the crab will reach the rightmost cell of a row of \( n \) cells. We will analyze the movement rules and derive the necessary conditions for Arepito to reach the end.

1. **Define the Problem and Notation:**
   - Let \( n \) be the number of cells.
   - Each cell is either blue (B) or red (R).
   - A block is a sequence of consecutive cells of the same color.
   - Arepito starts at the leftmost cell and moves according to the rules:
     - If on a blue cell and there are at least \( m \) cells to the right, move \( m \) cells to the right.
     - If on a red cell and there are at least \( m \) cells to the left, move \( m \) cells to the left.
     - Otherwise, stay on the same cell.

2. **Analyze the Movement:**
   - Let \( m_i \) be the size of the \( i \)-th block from the left.
   - Arepito will move from one block to another based on the size of the block he is currently on.
   - To ensure Arepito reaches the rightmost cell, we need to ensure that he can always move right until he reaches the end.

3. **Determine the Minimum Number of Blue Cells:**
   - We need to ensure that the sequence of blue blocks allows Arepito to move continuously to the right.
   - Consider the worst-case scenario where the blocks are arranged such that Arepito needs to move through all blocks to reach the end.

4. **Construct a Valid Configuration:**
   - For \( n = 2x + 1 \) (odd \( n \)):
     - Arrange the cells as \( B^{x+1}R^x \).
     - Arepito starts on the first blue block of size \( x+1 \), moves \( x+1 \) cells to the right, and reaches the end.
   - For \( n = 2x \) (even \( n \)):
     - Arrange the cells as \( B^xR^{x-1}B \).
     - Arepito starts on the first blue block of size \( x \), moves \( x \) cells to the right, and reaches the end.

5. **Prove the Minimum Number of Blue Cells:**
   - For \( n = 2x + 1 \):
     - The minimum number of blue cells required is \( x+1 = \left\lceil \frac{n+1}{2} \right\rceil \).
   - For \( n = 2x \):
     - The minimum number of blue cells required is \( x = \left\lceil \frac{n+1}{2} \right\rceil \).

6. **Conclusion:**
   - In both cases, the minimum number of blue cells required for Arepito to reach the rightmost cell is \( \left\lceil \frac{n+1}{2} \right\rceil \).

The final answer is \( \boxed{ \left\lceil \frac{n+1}{2} \right\rceil } \)