diff --git a/buggy.py b/buggy.py
--- a/buggy.py
+++ b/buggy.py
@@ -4,6 +4,8 @@
 l = -1
 r = N
 for m in range(1, N + 1):
+    if N % m != 0:
+        continue
     d = [[0 for i in range(26)] for j in range(m)]
     c = [0 for i in range(m)]
     for i in range(N):
