Text Editor
A world-renowned company has developed a new, simplified version of its popular text editor. In this editor, the user can perform only 4 operations, each triggered by a specific key:
Print the character "A" in the editor - key "A" (adds the character to the end of the current line).
Select the entire line - key "S" (select).
Copy all selected characters to the clipboard - key "C" (copy).
Append the contents of the clipboard to the end of the current line - key "P" (paste), replacing the selected line with the clipboard contents.
Your task is to determine the maximum number of "A" characters that can be printed in the editor using N keystrokes, and to specify the sequence of operations that achieves this result.
Input
The input consists of a single integer N (0 < N < 50).
Output
On the first line of the output, print an integer representing the maximum number of "A" characters that can be printed with N keystrokes. On the second line, print the sequence of operations that leads to this result. If multiple sequences yield the same result, choose the one that minimizes the number of characters in the clipboard.
Note: For example, pressing the key "A" three times results in the line AAA. Pressing "S" selects all characters, "C" copies them to the clipboard, and "P" pastes the clipboard contents, replacing the selected line. Pressing "P" two more times appends the clipboard contents to the current line. This sequence uses 8 keystrokes to produce a line with 9 "A" characters.