#include <bits/stdc++.h>
using namespace std;
char s[10];
string f;
string k;
int main() {
  cin >> s;
  int ans = 0;
  int a = 0;
  int b = 0;
  a = (s[0] - '0') * 10 + (s[1] - '0');
  b = (s[3] - '0') * 10 + (s[4] - '0');
  int o = 0;
  o = (a % 10) * 10 + (a / 10);
  if (o == b) {
    cout << ans << endl;
    return 0;
  }
  if (a == 23 && b > 32) {
    ans = 60 - b;
  } else {
    int flag = 1;
    for (int i = a; i < 24; i++) {
      if (flag == 0) {
        break;
      }
      for (int j = 0; j < 60; j++) {
        if (i == a && j <= b) {
          continue;
        }
        ans += 1;
        int c = (i % 10) * 10 + (i / 10);
        if (c == j) {
          flag = 0;
          break;
        }
      }
    }
  }
  cout << ans << endl;
}
