#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include<numeric>//gcd(,),lcm(,)
#include<cmath>//sin(),cos(),tan()  kodoho
#include<ctime>//jikan(clock.())
#include <stdio.h>
#include <cstring>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 10000000;
using ll = long long;


int main() {
	
	set<int>mar;
	set<int>bat;
	for (int i = 0; i < 10; i++) {
		char k;
		cin >> k;
		if (k == 'o') {
			
			mar.insert(i);
		}
		if (k == 'x') {
			
			bat.insert(i);
		}
		
	}
	ll ans = 0;
	for (int i = 0; i <= 9999; i++) {
		set<int>L = mar;
		
		bool OK = true;
		for (int h = 0; h<4; h++) {
			int c = pow(10, h);
			int G = i /c ;
			G = G % 10;
			if (L.count(G)) {
				L.erase(G);
			}
			if (bat.count(G)) {
				OK = false;
				break;
			}
			

		}
		if (OK == true) {
			if (L.empty()) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}
#include <bits/stdc++.h>

using namespace std;

typedef long long i64;
typedef unsigned long long ui64;
typedef vector<i64> vi;
typedef vector<vi> vvi;
typedef pair<i64, i64> pi;

#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)
inline void RI(i64 &i) {scanf("%lld", &(i));}
inline void RVI(vi &v) { for(i64 i=0;i<sz(v);++i) { RI(v[i]); } }
inline void RVVI(vvi &vv) { for(i64 i=0;i<sz(vv);++i) { RVI(vv[i]); } }
#define BUF_LENGTH 1000000
inline void RS(string &s) {static char buf[BUF_LENGTH]; scanf("%s", buf); s = buf;}
template<typename T> inline bool IN(T &S, const typename T::key_type &key) {
  return S.find(key) != S.end();
}

class SegTree {
public:
  ////////////////////////////////////////////////////////
  // monoid
  using X = long long;
  X X_dot_X(const X &v1, const X &v2) {
    return v1 + v2;
  }
  const X X_unit = 0;
  ////////////////////////////////////////////////////////
  typedef size_t idx_type;
  
  vector<X> data;

  idx_type n;
	
  SegTree(idx_type n_) {
    n = 1;
    while(n <= size_t(n_)) {
      n *= 2;
    }
    data.resize(n * 2 - 1, X_unit);
  }
  ~SegTree() {}
  
  X query(idx_type a, idx_type b, idx_type k, idx_type l, idx_type r) {
    if(r <= a || b <= l) {
      return X_unit;
    }
		
    if(a <= l && r <= b) {
      return data[k];
    }
    else {
      X vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
      X vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
      return X_dot_X(vl, vr);
    }
  }
  
  X query(idx_type a, idx_type b) {
    return query(a, b, 0, 0, n);
  }
	
  void update(idx_type i, X x) {
    i += n - 1;
    data[i] = x;
    while(i > 0) {
      i = (i - 1) / 2;
      data[i] = X_dot_X(data[i*2+1], data[i*2+2]);
    }
  }
};


int main(int argc, char *argv[]) {
  i64 H, W, M, i, x;
  cin >> H >> W >> M;
  map<i64, vi> D;
  REP(0, M, i) {
    i64 x, y;
    cin >> y >> x;
    x--; y--;
    D[y].pb(x);
  }
  for(auto &p: D) {
    sort(all(p.second));
  }

  if(D.empty()) {
    cout << H*W << endl;
    return 0;
  }

  i64 y_prev = -1;
  i64 ans = 0;
  bool blk = false;
  SegTree tree(W);
  REP(0, W, x) {
    tree.update(x, 1);
  }
  for(auto &d: D) {
    const i64 &y = d.first;
    vi &v = d.second;
    if(y == 0) {
      i64 x0 = v[0];
      REP(x0, W, x) {
        tree.update(x, 0);
      }
      ans += x0;
    }
    else {
      i64 dy = y - y_prev - 1;
      if(blk) {
        ans += dy * tree.query(0, W);
        //cerr << "interval " << dy * tree.query(0, W) << endl;
      }
      else {
        ans += dy * W;
        //cerr << "interval " << dy * W << endl;
      }
      for(auto &vv: v) {
        tree.update(vv, 0);
      }      

      i64 x0 = v[0];
      if(x0 == 0) {
        blk = true;
      }

      if(blk) {
        ans += tree.query(0, W);
      }
      else {
        ans += tree.query(x0, W) + x0;
      }
      //cerr << "y " << tree.query(x0, W) + x0 << endl;
    }
    //cerr << y_prev << " " << y << " " << ans << endl;
    y_prev = y;
  }
  if(blk) {
    ans += (H - y_prev - 1) * tree.query(0, W);
  }
  else {
    ans += (H - y_prev - 1) * W;
  }
  cout << ans << endl;

  return 0;
}

