How to find shortest prefix suffix greater than zero if exist

For this problem Periods of Words . If we find the smallest prefix suffix of each prefix and subtract it from the length of the prefix string then we get the answer as per my thinking if it is not zero.

But How to find the smallest prefix suffix?