[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
n, m = integers
la, lb = integers both with value of 1
vis = integer array of length 10
ans = integer with value o f0
in function dfs2 that returns nothing and takes arguments k, num = integers
    if k equals lb
        add 1 to ans
        return
    end of the block
    for i = 0 to 6 inclusive
        if vis[i] equals 0 and num * 7 + i is less than m
            set vis[i] to 1
            call dfs2 with arguments k+1 and num*7+i
            set vis[i] to 0
        end of the block
    end of the block
end of the block
in function dfs1 that returns nothing and take arguments k, num = integer
    if k equals la
        call dfs2 with arguments 0 and 0
        return
    end of the block
    for i = 0 to 6 inclusive
        if vis[i] equals 0 and num*7+i is less than n
            set vis[i] to 1
            call dfs1 with arguments k+1 and num*7+i
            set vis[i] to 0
        end of the block
    end of the block
end of the block
define the main function
    read n and m
    fn, fm = integers with fn value of n and fm value of m
    if n is greater than 0 subtract 1 from n
    if m is greater than 0 subtract 1 from m
    while n/7
        add 1 to la
        set n to n/7
    end of the block
    while m/7
        add 1 to lb
        set m to m/7
    end of the block
    set n to fn and m to fm
    if la+lb is greater than 7
        print 0
        return to indicate successful execution
    end of the block
    call dfs1 with argument of 0 and 0
    print ans
    return to indicate successful execution
end of the block

[CODE]:

int n, m;
int la = 1, lb = 1;
int vis[10];
int ans = 0;
void dfs2(int k, int num) {
    if (k == lb) {
        ans++;
        return;
    }
    for (int i = 0; i <= 6; i++) {
        if (vis[i] == 0 && num * 7 + i < m) {
            vis[i] = 1;
            dfs2(k + 1, num * 7 + i);
            vis[i] = 0;
        }
    }
}
void dfs1(int k, int num) {
    if (k == la) {
        dfs2(0, 0);
        return;
    }
    for (int i = 0; i <= 6; i++) {
        if (vis[i] == 0 && num * 7 + i < n) {
            vis[i] = 1;
            dfs1(k + 1, num * 7 + i);
            vis[i] = 0;
        }
    }
}
int main() {
    cin >> n >> m;
    int fn = n, fm = m;
    if (n > 0) n--;
    if (m > 0) m--;
    while (n / 7) {
        la++;
        n /= 7;
    }
    while (m / 7) {
        lb++;
        m /= 7;
    }
    n = fn, m = fm;
    if (la + lb > 7) {
        cout << 0 << endl;
        return 0;
    }
    dfs1(0, 0);
    cout << ans << endl;
    return 0;
}