Longest Repeating Subsequence

medium
1. You are given a string str.
2. You have to find the length of longest subsequence which is appearing twice in the string.
3. Every ith character in both the subsequences must have different indices in the original string. 

Input Format

A string str

Output Format

A number representing the length of longest repeating subsequence.

Constraints

1 < length of strings str <= 2000

Example

Input
abcdgh
Output
0
Previous
Wildcard Pattern Matching
Next
Kadane's Algorithm

Related Questions