fail2ban for vpn retries script

hello awesome people
i am looking to protect my mikrotik router acting as vpn router from bruteforce , i am seeing a lot of failed vpn retries from unknown IPs in my log
I am looking for 2 things :
1- block same external ip if it fails more than 3 times
2- block any ip if there is more than 10 login incorrect answers per minute

I found this but i am not able to edited to make it work :

https://wiki.mikrotik.com/wiki/Bruteforce_login_prevention

can you please help out