#include <bits/stdc++.h>
using namespace std;
const int maxn = 100001;
vector<int> v, w;
char s[1000001];
int main() {
  scanf("%s", &s);
  int len = strlen(s);
  for (int i = (0); i < (len); i++) {
    if (s[i] == '@') v.push_back(i);
    if (s[i] == '.') w.push_back(i);
  }
  int t = 0, tmp = 0;
  long long ans = 0;
  while (t < v.size() && tmp < w.size()) {
    long long first = 0, mid = 1, last = 0;
    if (t == v.size()) break;
    while (v[t] > w[tmp] && tmp < w.size()) tmp++;
    if (tmp == w.size()) break;
    if (v[t] + 1 == w[tmp]) mid = 0;
    for (int i = v[t] + 1; i < w[tmp]; i++) {
      if ((s[i] > '9' || s[i] < '0') && (s[i] > 'z' || s[i] < 'a')) {
        mid = 0;
        break;
      }
    }
    if (!mid) {
      t++;
      continue;
    }
    if (v[t] > 0)
      for (int i = v[t] - 1; i >= 0; i--) {
        if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= '0' && s[i] <= '9') ||
            s[i] == '_') {
          if (s[i] >= 'a' && s[i] <= 'z') first++;
        } else
          break;
      }
    if (w[tmp] + 1 < len)
      for (int i = w[tmp] + 1; i < len; i++) {
        if (s[i] >= 'a' && s[i] <= 'z')
          last++;
        else
          break;
      }
    ans += first * last;
    t++;
  }
  cout << ans << endl;
  return 0;
}
