import math._ object Main { def main(args: Array[String]) { val sc = new java.util.Scanner(System.in) var g, c, p = sc.nextInt val s = sc.next var ans = 0 var ng = s.count(_ == 'G') var nc = s.count(_ == 'C') var np = s.count(_ == 'P') val mg = min(g, nc) val mc = min(c, np) val mp = min(p, ng) ans += 3 * (mg + mc + mp) g -= mg nc -= mg c -= mc np -= mc p -= mp ng -= mp ans += min(g, ng) + min(c, nc) + min(p, np) println(ans) } }