eolymp
bolt
Try our new interface for solving problems
Problems

Reduction

Reduction

You are given string \textbf{S} and list \textbf{M}, consisting of \textbf{N} words, each has length \textbf{L}. During an operation you may choose substring of string \textbf{S}, if it can be found as word in list \textbf{M}, and cut it out of string \textbf{S}. Then remaining parts of string \textbf{S}, are merged if there are any. Determine minimal amount of opertions required to erase whole string \textbf{S}. It is guaranteed that it can be done. \InputFile The frist line has word \textbf{S}. Second line contains integer \textbf{N}, that is amount of words in the list. It is followed by \textbf{N} lines listing words from \textbf{M}. All words consist of lowercase latin letters only. \OutputFile Output an integer, that is minimal number of opertions required to erase whole string \textbf{S}. \textbf{Limits} \textbf{1} ≤ \textbf{|S|} ≤ \textbf{100} \textbf{1} ≤ \textbf{N} ≤ \textbf{100} \textbf{1} ≤ \textbf{|M_i|} ≤ \textbf{100} \textbf{1} ≤ \textbf{L} ≤ \textbf{|S|}
Time limit 1 second
Memory limit 256 MiB
Input example #1
abacabada
4
aba
aca
ada
abb
Output example #1
3