electicode
HomeCoursesResourcesProblemsNational OlympiadContestsLeaderboard
...

ABABABA2026

Time Limit: 1000msMemory Limit: 256MB
View Submissions

Problem Description

In the alphabet, there are only two letters: A and B.

We consider strings of length nnn consisting only of these letters.

A string is called correct if all the following conditions are met:

  • the first and last letters are A;
  • there are no two As in a row (the substring AA is forbidden);
  • there are no three Bs in a row (the substring BBB is forbidden).

For example, the strings ABBA, ABABABA, ABBABABBA are correct, while the strings ABBAB, ABAABA, ABABBBA are not.

We need to find the number of correct strings of length nnn.

Input

The first line contains one integer nnn (4≤n≤106)(4 \le n \le 10^6)(4≤n≤106) — the length of the string.

Output

Output the number of correct strings of length nnn modulo 998244353998244353998244353.

Scoring System

SubtasksAdditional ConstraintsPointsRequired Subtasks
0Example0—
1n≤10n \le 10n≤10100
2n≤1000n \le 1000n≤100030

Examples

Example 1
Input
4
Output
1
Example 2
Input
6
Output
2

© 2026 Electicode. All rights reserved.

0, 1
4—600, 1, 2