#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000005;
int N;
int R[MAX_N], p[MAX_N];
long long sol;
char s[MAX_N];
int main() {
  s[0] = ' ';
  scanf("%s", s + 1);
  N = strlen(s) - 1;
  for (int i = 1; i <= N; ++i)
    if (s[i] == '.') {
      for (int j = i + 1; j <= N && (s[j] >= 'a' && s[j] <= 'z'); ++j) ++R[i];
    } else if (s[i] == '@') {
      for (int j = i + 1; j <= N; ++j)
        if (s[j] == '_' || s[j] == '@')
          j = N;
        else if (s[j] == '.') {
          p[i] = j;
          j = N;
        }
    }
  for (int i = 1; i <= N; ++i)
    if (s[i] == '@') {
      if (s[i + 1] == '.') continue;
      int x = i + 1, l = 0, ok = 1;
      while (x <= N && s[x] != '.' && ok) {
        if (s[x] == '@' || s[x] == '_') ok = 0;
        ++x;
      }
      if (ok) {
        ++x;
        while (x <= N && s[x] >= 'a' && s[x] <= 'z') ++x, ++l;
      }
      for (int j = i - 1; j >= 1; --j)
        if (s[j] == '@' || s[j] == '.')
          j = 1;
        else if (s[j] >= 'a' && s[j] <= 'z')
          sol += l;
    }
  cout << sol << "\n";
  return 0;
}
