#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000000 + 5;
const int INF = 1000000000 + 7;
char s[maxn];
int n;
long long ans;
bool isletter(char s) { return s >= 'a' && s <= 'z'; }
bool isdigit(char s) { return s >= '0' && s <= '9'; }
void solve(int pos_start) {
  if (pos_start >= n - 1) return;
  while (1) {
    if (pos_start >= n - 1) return;
    long long ansL = 0;
    int pos_at = -1;
    for (int i = pos_start; i < n; i++) {
      if (isletter(s[i]) || s[i] == '_' || isdigit(s[i])) {
        if (isletter(s[i])) ansL++;
      } else if (s[i] == '@') {
        pos_at = i;
        break;
      } else {
        ansL = 0;
      }
    }
    if (pos_at == -1) return;
    int pos_dot = -1;
    int tag = 1;
    for (int i = pos_at + 1; i < n; i++) {
      if (s[i] == '.' && i == pos_at + 1) {
        pos_start = pos_at + 1;
        tag = 0;
        break;
      }
      if (s[i] == '.') {
        pos_dot = i;
        break;
      } else if (!(isdigit(s[i]) || isletter(s[i]))) {
        pos_start = pos_at + 1;
        tag = 0;
        break;
      }
    }
    if (pos_dot == -1) tag = 0;
    if (tag == 0) {
      pos_start = pos_at + 1;
      continue;
    }
    long long ansR = 0;
    for (int i = pos_dot + 1; i < n; i++) {
      if (isletter(s[i]))
        ansR++;
      else
        break;
    }
    ans += ansL * ansR;
    pos_start = pos_dot + 1;
  }
}
int main() {
  while (scanf("%s", s) != EOF) {
    n = strlen(s);
    ans = 0;
    solve(0);
    printf("%I64d\n", ans);
  }
  return 0;
}
