diff --git a/buggy.py b/buggy.py
--- a/buggy.py
+++ b/buggy.py
@@ -13,7 +13,7 @@
 X = [(D[l], D[r]) for l, r in X]
 d = 0
 s = 1
-while s < M:
+while s < M - 1:
     s *= 2
     d += 1
 L = [0] * (M + 1)
