#include <bits/stdc++.h>
using namespace std;
int to_i(string s) {
  stringstream ss;
  ss << s;
  int x;
  ss >> x;
  return x;
}
int main() {
  string s;
  cin >> s;
  long long ans = 0;
  for (int i = s.size() - 1; i >= 0; i--) {
    if ((s[i] - '0') % 4 == 0) ans++;
    if (i != 0) {
      int st = ((s[i - 1] - '0') * 10) + (s[i] - '0');
      if (st % 4 == 0) {
        ans = ans + i;
      }
    }
  }
  cout << ans << endl;
}
