diff --git a/buggy.py b/buggy.py
--- a/buggy.py
+++ b/buggy.py
@@ -8,6 +8,9 @@
     S = input()
 
     for i in range(1, N + 1):
+        if N % i:
+            continue
+
         D = [[0 for _ in range(26)] for _ in range(i)]
         T = [0 for _ in range(i)]
 
