I want to show that $L = \{ a^k w b^k \mid k \geq 0, w \in \{a,b\}^*, |w|_a \text{is divisible by } 3 \}$ is not regular.
I tried to use Pumping lemma as follows: Let $p$ be pumping length. $a^pb^p \in L$. By pumping lemma, then $a^{p+k}b^p$ is in $L$ too. If $k$ is not divisible by 3, then we have a contradiction. If $k$ is divisible by 3, then $(k-1)$ is not. String $a^{p-1}b^{p-1} \in L$, then, I thought, by pumping lemma $a^{p-1-(k-1)}(a^{k-1}b^1)(b^{p-1})$. But then I realised that the number of letters I can pump is different in that case (since the first $p$ letters are different).
So, now I am quite lost, any advice is appreciated. Thanks.