#include <bits/stdc++.h>
using namespace std;
int type[256];
vector<int> cnt[5];
vector<int> nextchar[5];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  for (char c : "abcdefghijklmnopqrstuvwxyz") {
    type[(int)c] = 0;
  }
  for (char c : "0123456789") {
    type[(int)c] = 1;
  }
  type[(int)'_'] = 2;
  type[(int)'@'] = 3;
  type[(int)'.'] = 4;
  for (int i = 0; i < 5; i++) {
    cnt[i].resize(n + 1, 0);
    nextchar[i].resize(n + 1, n);
  }
  for (int j = n - 1; j >= 0; j--) {
    for (int i = 0; i < 5; i++) nextchar[i][j] = nextchar[i][j + 1];
    nextchar[type[(int)s[j]]][j] = j;
  }
  for (int j = 0; j < n; j++) {
    for (int i = 0; i < 5; i++) cnt[i][j + 1] = cnt[i][j];
    cnt[type[(int)s[j]]][j + 1] += 1;
  }
  long long result = 0;
  for (int ml = 0; ml < n - 1; ml++)
    if (s[ml] == '@') {
      int mr = nextchar[4][ml + 2] + 1;
      {
        int validcnt = 0;
        for (int i = 0; i < 2; i++) validcnt += cnt[i][mr] - cnt[i][ml];
        if (validcnt != mr - ml - 2) continue;
      }
      if (mr < nextchar[3][ml + 1]) {
        int l = ml;
        for (int tpow = 1 << 19; tpow > 0; tpow /= 2)
          if (tpow <= l) {
            int prev = l - tpow;
            int validcnt = 0;
            for (int i = 0; i < 3; i++) validcnt += cnt[i][ml] - cnt[i][prev];
            if (validcnt == ml - prev) l = prev;
          }
        int r = mr;
        for (int tpow = 1 << 19; tpow > 0; tpow /= 2)
          if (r + tpow <= n) {
            int next = r + tpow;
            if (cnt[0][next] - cnt[0][mr] == next - mr) r = next;
          }
        result += 1LL * (r - mr) * (cnt[0][ml] - cnt[0][l]);
      }
    }
  cout << result << '\n';
  return 0;
}
