#include <bits/stdc++.h>
using namespace std;
void fre() {
  freopen("c://test//input.in", "r", stdin);
  freopen("c://test//output.out", "w", stdout);
}
template <class T1, class T2>
inline void gmax(T1 &a, T2 b) {
  if (b > a) a = b;
}
template <class T1, class T2>
inline void gmin(T1 &a, T2 b) {
  if (b < a) a = b;
}
const int N = 1e6 + 10, M = 0, Z = 1e9 + 7, ms63 = 0x3f3f3f3f;
char s[N];
int nxt0[N];
int nxt1[N];
int nxt2[N];
int bef[N];
int beh[N];
int main() {
  while (~scanf("%s", s)) {
    int last = -1;
    int beff = 0;
    for (int i = 0; s[i]; ++i) {
      if (s[i] == '@') {
        if (~last) gmin(nxt0[last], i);
        last = i;
        nxt0[last] = nxt1[last] = nxt2[last] = 1e9;
        bef[i] = beff;
        beff = 0;
      } else if (s[i] == '.') {
        gmin(nxt1[last], i);
        beff = 0;
      } else if (s[i] == '_') {
        gmin(nxt2[last], i);
      } else if (isalpha(s[i])) {
        ++beff;
      }
    }
    int behh = 0;
    for (int i = strlen(s) - 1; ~i; --i) {
      if (s[i] == '@') {
        behh = 0;
      } else if (s[i] == '.') {
        beh[i] = behh;
        behh = 0;
      } else if (s[i] == '_') {
        behh = 0;
      } else if (isdigit(s[i])) {
        behh = 0;
      } else {
        ++behh;
      }
    }
    long long ans = 0;
    for (int i = 0; s[i]; ++i) {
      if (s[i] == '@') {
        if (nxt1[i] < nxt0[i] && nxt1[i] < nxt2[i] && nxt1[i] > i + 1) {
          ans += (long long)bef[i] * beh[nxt1[i]];
        }
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}
