diff --git a/buggy.py b/buggy.py
--- a/buggy.py
+++ b/buggy.py
@@ -22,7 +22,7 @@
             u = q.pop()
             for v in E[u]:
                 if -1 < A[v] <= K:
-                    memo[A[v]] += 1
+                    memo[A[v]] = 1
                 elif A[v] == -1:
                     cnt += 1
                 q.append(v)
