#include <bits/stdc++.h>
using namespace std;
int p[20000][10];
int messageOut[20000];
int messageIn[10];
int isValid(int begin, int end, string &s) {
  if (end - begin < 0) return 0;
  for (int i = begin; i <= end; i++)
    if (!isalnum(s[i])) return 0;
  return 1;
}
int suffix(int pos, string &s) {
  int res = 0;
  for (int i = pos + 1; i < s.length(); i++)
    if (isalpha(s[i]))
      res++;
    else
      break;
  return res;
}
int prefix(int pos, string &s) {
  int res = 0;
  for (int i = pos - 1; i >= 0; i--)
    if (isalnum(s[i]) || s[i] == '_') {
      if (isalpha(s[i])) res++;
    } else
      break;
  return res;
}
int main() {
  string s;
  cin >> s;
  vector<pair<int, int> > pairs;
  vector<int> ats, dots;
  int l = s.length();
  for (int i = 0; i < l; i++) {
    if (s[i] == '@') ats.push_back(i);
    if (s[i] == '.') dots.push_back(i);
  }
  for (int i = 0; i < ats.size(); i++) {
    vector<int>::iterator nxt;
    nxt = upper_bound(dots.begin(), dots.end(), ats[i]);
    if ((nxt != dots.end()) &&
        (i + 1 == ats.size() || (i + 1 < ats.size() && *nxt < ats[i + 1]))) {
      if (isValid(ats[i] + 1, *nxt - 1, s))
        pairs.push_back(make_pair(ats[i], *nxt));
    }
  }
  long long answer = 0;
  for (int i = 0; i < pairs.size(); i++) {
    answer += 1ll * suffix(pairs[i].second, s) * prefix(pairs[i].first, s);
  }
  cout << answer << endl;
  return 0;
}
