#include <bits/stdc++.h>
using namespace std;
void solve(int ncase) {
  string str;
  cin >> str;
  long long ans = 0;
  int headcnt = 0, midcnt = 0, midnum = 0, tailcnt = 0, status = 0;
  for (int i = 0; i < str.size(); i++) {
    if (status == 0) {
      if (str[i] >= 'a' && str[i] <= 'z') {
        headcnt++;
      } else if (str[i] >= '0' && str[i] <= '9') {
        ;
      } else if (str[i] == '.') {
        headcnt = 0;
      } else if (str[i] == '_') {
        ;
      } else if (str[i] == '@') {
        status = 1;
        midcnt = 0;
        midnum = 0;
      }
      continue;
    }
    if (status == 1) {
      if (str[i] >= 'a' && str[i] <= 'z') {
        midcnt++;
      } else if (str[i] >= '0' && str[i] <= '9') {
        midnum++;
      } else if (str[i] == '.') {
        if (midcnt || midnum) {
          status = 2;
          tailcnt = 0;
        } else {
          status = 0;
          headcnt = 0;
        }
      } else if (str[i] == '_') {
        status = 0;
        headcnt = midcnt;
      } else if (str[i] == '@') {
        if (midcnt) {
          status = 1;
          headcnt = midcnt;
          midcnt = 0;
          midnum = 0;
        } else {
          status = 0;
          headcnt = 0;
        }
      }
      continue;
    }
    if (status == 2) {
      if (str[i] >= 'a' && str[i] <= 'z') {
        tailcnt++;
      } else {
        ans += headcnt * 1LL * tailcnt;
        status = 0;
        headcnt = 0;
        if (str[i] >= '0' && str[i] <= '9') {
          headcnt = tailcnt;
        } else if (str[i] == '.') {
        } else if (str[i] == '_') {
          headcnt = tailcnt;
        } else if (str[i] == '@') {
          if (tailcnt) {
            headcnt = tailcnt;
            midcnt = 0;
            midnum = 0;
            status = 1;
          }
        }
      }
      continue;
    }
  }
  if (status == 2) {
    ans += headcnt * 1LL * tailcnt;
  }
  cout << ans << endl;
}
int main() {
  int T = 1;
  int ncase = 0;
  while (T--) {
    solve(++ncase);
  }
}
