#!/usr/bin/env python3 g, c, p = map(int,input().split()) s = input() a = [ [g, c, p], [s.count(it) for it in 'GCP'] ] ans = 0 for i in range(3): j = (i+1) % 3 k = min(a[0][i], a[1][j]) ans += 3 * k a[0][i] -= k a[1][j] -= k for i in range(3): k = min(a[0][i], a[1][i]) ans += k a[0][i] -= k a[1][i] -= k print(ans)