#include <bits/stdc++.h>
using namespace std;
const int MX = 300005;
string a;
long long dp[MX][4];
int main() {
  cin >> a;
  memset(dp, 0, sizeof(dp));
  long long res = 0;
  for (int i = 0; i < a.length(); i++) {
    dp[i + 1][(a[i] - '0') % 4] += 1;
    for (int j = 0; j < 4; j++) {
      dp[i + 1][(j * 10 + a[i] - '0') % 4] += dp[i][j];
    }
    res += dp[i + 1][0];
  }
  cout << res << endl;
  return 0;
}
