QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 100

#11190. Signboard

Statistics

Bajtazar is opening a new warehouse. He would like a large sign with a certain inscription to hang above the entrance. This inscription should contain the name of his company as a contiguous substring as many times as possible, where these occurrences may overlap.

Taught by experience, Bajtazar knows he must watch out for vandals who destroy signs. He fears that hooligans might try to erase some letters from the sign in such a way that the remaining (unerased) letters form the name of a competing company. He would therefore like to choose the inscription on the sign such that this is not possible. Can you help him?

Input

The first line of input contains a word that is the name of Bajtazar's company. The second line of input contains a word that is the name of the competing company. Both words are non-empty and consist of lowercase and/or uppercase English letters and/or digits. Note: case sensitivity applies when comparing strings.

Output

The first and only line of output should contain a single integer – the maximum possible number of occurrences of Bajtazar's company name in an inscription that satisfies the problem conditions.

If Bajtazar's company name can appear in the inscription an arbitrarily large number of times, output the word INF instead.

Examples

Input 1

karolek
lololek

Output 1

2

Note

Bajtazar can place, for example, the inscription karolekarolek on the sign. Placing the word karolek three times on the sign inevitably leads to the possibility of erasing some letters so that the word lololek remains.

Subtasks

The test set is divided into the following subtasks. Tests for each subtask consist of one or more separate test groups. Let $n$ denote the constraint on the length of both company names.

Subtask Constraints Points
1 $n \le 5000$ 20
2 $n \le 50\,000$ 30
3 $n \le 1\,000\,000$ 50

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.