#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int a, b, count = 1;
vector <int> vec;
string str;
getline(cin, str);
int n = str.length();
for (int i = 1; i < n; i++) if (str[i - 1] != str[i]) {
vec.push_back(count);
count = 1;
} else count++;
vec.push_back(count);
cin >> a >> b;
int sum = 0;
for (int e : vec) sum += e;
int len = vec.size();
cout << a * sum + ((b < 0) ? (len / 2 + 1) : len) * b;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwogCmludCBtYWluKCkgewogaW50IGEsIGIsIGNvdW50ID0gMTsKIHZlY3RvciA8aW50PiB2ZWM7CiBzdHJpbmcgc3RyOwogZ2V0bGluZShjaW4sIHN0cik7CiBpbnQgbiA9IHN0ci5sZW5ndGgoKTsKIGZvciAoaW50IGkgPSAxOyBpIDwgbjsgaSsrKSBpZiAoc3RyW2kgLSAxXSAhPSBzdHJbaV0pIHsKICAgICAgICB2ZWMucHVzaF9iYWNrKGNvdW50KTsKICAgICAgICBjb3VudCA9IDE7CiAgICB9IGVsc2UgY291bnQrKzsKIHZlYy5wdXNoX2JhY2soY291bnQpOwogY2luID4+IGEgPj4gYjsKIGludCBzdW0gPSAwOwogZm9yIChpbnQgZSA6IHZlYykgc3VtICs9IGU7CiBpbnQgbGVuID0gdmVjLnNpemUoKTsKIGNvdXQgPDwgYSAqIHN1bSArICgoYiA8IDApID8gKGxlbiAvIDIgKyAxKSA6IGxlbikgKiBiOwogcmV0dXJuIDA7Cn0=