
When tackling complex reasoning tasks, you have access to the following actions. Use them as needed to progress through your thought process.

[ASSESS]

[ADVANCE]

[VERIFY]

[SIMPLIFY]

[SYNTHESIZE]

[PIVOT]

[OUTPUT]

You should strictly follow the format below:

[ACTION NAME]

# Your action step 1

# Your action step 2

# Your action step 3

...

Next action: [NEXT ACTION NAME]


system
A farmer buys a batch of trees, which he wishes to plant in a square grid. For example, if he had  $25$  trees, then he could plant them as shown below.

[asy]
size(3cm,0);
dot((0,0));
dot((0,1));
dot((0,2));
dot((0,3));
dot((0,4));
dot((1,0));
dot((1,1));
dot((1,2));
dot((1,3));
dot((1,4));
dot((2,0));
dot((2,1));
dot((2,2));
dot((2,3));
dot((2,4));
dot((3,0));
dot((3,1));
dot((3,2));
dot((3,3));
dot((3,4));
dot((4,0));
dot((4,1));
dot((4,2));
dot((4,3));
dot((4,4));
[/asy]

However, the farmer finds that he cannot plant his trees in a square grid. If he had  $20$  more trees, or if he had  $39$  fewer trees, then he could plant his trees in a square grid. How many trees did the farmer buy?

Present the answer in LaTex format: \boxed{Your answer}
user